Event Sourcing: Storing State as an Immutable Event Log
Fast recall
Quick revision
Core answer
Whether you understand the difference between storing state vs storing events, and can articulate real trade-offs
Thinking event sourcing means just publishing events to Kafka — event sourcing specifically means the event log IS the source of truth for entity state
Discuss snapshots for performance, projections for read models, and mention that CQRS is a natural companion to event sourcing
Interview-ready guide
Interview answer
Event sourcing is often confused with simply publishing events to Kafka.
- It is actually a persistence model where the event log is the source of truth for entity state.
- Instead of
UPDATE orders SET status = 'SHIPPED'— which destroys history — you append anOrderShippedevent. - Current state is always derived by replaying the full event stream from the beginning.
The real benefits:
- A complete audit trail as the core mechanism, not an afterthought added later — every state transition is preserved by the fundamental design
- Temporal queries become possible: "what was this order's state last Tuesday at 3pm?" — replay events up to that timestamp and you get the exact state
- Since events are already persisted, publishing them to Kafka or other consumers requires no additional work — the event log IS the source
The real costs:
- Reading current state requires replaying all events for an aggregate — for an order with 500 events, that's 500 state transitions before you can handle a new command; snapshots solve this by periodically materializing state so you only replay events since the last snapshot
- Queries are harder — you cannot write a SQL JOIN across event streams, so you build read-side projections (materialized views) optimized for specific queries; this is why event sourcing almost always comes paired with CQRS
- Schema evolution requires upcasters — you cannot ALTER a historical event, so breaking schema changes need transformers that convert old formats during replay
When to use it:
- Domains where history is as important as current state: financial ledgers, order management, compliance-heavy systems
- For standard CRUD with simple reporting needs, the operational complexity of snapshots, projections, and event schema evolution is not justified
I recommend event sourcing only when the domain genuinely requires a complete audit trail or temporal queries — the operational overhead is real and should only be accepted when the domain benefit is proportional.
Event Sourcing: Storing State as an Immutable Event Log
Direct Answer
event sourcing stores the history of state changes as an immutable sequence of events rather than current state. To GET current state, replay all events. Benefits include full audit trail, temporal queries (state at any point in time), and natural fit with event-driven systems. Costs include query complexity, eventual consistency, and the need for snapshots as event logs grow.
Common Mistakes & Pitfalls
Thinking event sourcing means just publishing events to Kafka — event sourcing specifically means the event log IS the source of truth for entity state
Check your understanding
Answer these without looking back at the article.
- How do snapshots work in an event-sourced system?
- What is a projection and how does it differ from the event store?
- How do you handle event schema evolution when events are immutable historical records?
Related interview prep categories
2Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.