← Back to microservices patterns mapevents
Microservices Pattern
Event Sourcing
Store every state change as an immutable event and rebuild state by replaying events.
Detailed Description
Event sourcing stores history, not just current state. This is powerful for audit-heavy domains.
The cost is that event schemas live forever and projections must be maintained carefully.
Visual Diagram
Event Store (append-only log)
[1] AccountCreated { userId: 1, balance: 0 }
[2] MoneyDeposited { userId: 1, amount: 500 }
[3] MoneyWithdrawn { userId: 1, amount: 200 }
[4] MoneyDeposited { userId: 1, amount: 100 }
Replay 1→4: balance = 0+500-200+100 = 400
Time travel: replay 1→2 = balance = 500Tradeoffs
Pros
Full audit trail, temporal debugging
Cons
Complex modeling and event versioning
Examples: EventStoreDB, Axon, custom event logs
Comments
Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.
Loading comments...
On this page
0 sections