Event Sourcing
Subject: Computer and Technology noun /ɪˈvɛnt ˈsɔːr.sɪŋ/ 1 definition
- software-architecture
- distributed-systems
- database-systems
- event-driven-architecture
-
Definition (noun)
Entry #75 · UpdatedEvent Sourcing is a software architecture and data persistence pattern in which every change to an application's state is captured and stored as an immutable, chronologically ordered event in an append-only log. Instead of mutating records in place within a state table, the system reconstructs an entity's current state at any time by replaying its recorded event stream from inception or from a prior checkpoint. Rather than functioning as a general-purpose query engine itself, event sourcing provides an authoritative, auditable record of state transitions that decouples write-side persistence from downstream read models and analytical projections.
Common Forms
Pure (Full-Replay) Event Sourcing: Stores solely the append-only stream of domain events for each entity or aggregate, deriving current state exclusively by replaying every event from the start of the stream.
Snapshotted Event Sourcing: Periodically saves serialized point-in-time state checkpoints alongside the event log so entity hydration only replays events appended after the latest snapshot, bounding read latency for long-lived streams.
CQRS-Paired Event Sourcing: Combines an append-only event store on the write side with Command Query Responsibility Segregation (CQRS), continuously projecting emitted events into separate, query-optimized read databases.
Bi-Temporal Event Sourcing: Records both when an event occurred in the domain and when it was persisted to the store, supporting point-in-time audits, retroactive corrections, and historical state reconstruction.
Example
When a customer manages a checking account, a banking ledger appends immutable events such as
AccountOpened($0),FundsDeposited($500), andFundsWithdrawn($120)to streamaccount-8492instead of updating a single mutablebalancerow. To serve a balance check or reconstruct account state as of a past audit timestamp, the service replays the stream in sequence to derive the$380balance while preserving a complete history of every transition.