Video in progress
When do you choose event sourcing, and when is it too heavy for a project?
When the history of events that led to the state matters to the business more than the state itself (a ledger, audit, a complex state machine), event sourcing pays off. In a plain CRUD domain it adds a permanent cost: schema evolution, projections and eventual consistency.
📖 Answer
In event sourcing the table has no "current state". Every change is written as an immutable event (AccountOpened, MoneyDeposited, MoneyWithdrawn), and the state is obtained by applying them in order. Separate projections (CQRS) are built for reads.
When it pays off:
- an auditor or regulator asks "how did this balance come about?" and the answer is a legal requirement;
- questions like "what was the state on the 15th of last month?" come up often;
- you need different views of the same events (report, search, notification) and they multiply over time;
- the domain itself speaks in events (booking, insurance claims, logistics).
When it's too much:
- the domain is mostly CRUD, like "edit profile". The events become
ProfileUpdatedand add no value; - the team is small and inexperienced. In event sourcing mistakes are expensive: a wrongly written event stays forever.
The permanent costs, which you need to know up front:
- Schema evolution. Events from 3 years ago must still be readable. Upcasters, or versioned event classes.
- Rebuilding projections. Replaying billions of events takes hours; you need snapshots.
- Eventual consistency in the read model: the user may not see what they just wrote.
- Deletion. A "delete my data" request collides with an immutable log; you'd have to encrypt the personal data inside events and delete the key (crypto-shredding).
I often recommend the middle road: a plain state table plus audit/outbox events written in the same transaction. It gives 80% of the value of history for 20% of the complexity. I apply full event sourcing only to one or two core parts of the system.
Sign up to mark studied questions and save your progress.