Explore event sourcing in Scala microservices as a way to persist domain facts and rebuild state from event history, with attention to replay cost, projection design, and event evolution.
Event sourcing: Persisting state changes as a sequence of domain events so current state can be reconstructed by replaying those events.
Event sourcing can be powerful in microservices when the history of change matters as much as current state. It is also one of the easiest patterns to over-adopt. The benefit is not “events are modern.” The benefit is a durable log of domain facts that supports audit, replay, and projection models when the domain truly needs them.
In a CRUD-style model, the system often stores only the latest state. In event sourcing, it stores a sequence such as:
Current state becomes a derived view over those facts.
That can be valuable when:
The hardest part is not wiring persistence APIs. It is deciding:
Weak event design creates permanent confusion because persisted events are not easy to “just refactor away.”
Event sourcing usually needs:
Without these, the system can become theoretically elegant but operationally painful. Rebuilding state is only valuable if the recovery and projection process is dependable enough to use under pressure.
Scala is a strong fit when events, commands, and aggregate states are modeled clearly with enums, case classes, and typed transitions.
That helps teams review:
The language advantage is not magic persistence. It is stronger modeling at a pattern where modeling quality matters enormously.
It is often the wrong fit when:
In those cases, ordinary persistence plus explicit audit logging may be the better design.
The event stream becomes a log of implementation details rather than stable business meaning.
The system writes events as if schemas will never need to change, then struggles later with replay and compatibility.
Read models fall behind or become inconsistent, and no one has a reliable replay or repair process.
Choose event sourcing when domain history, replay, and projection flexibility are genuinely valuable. Model events as durable business facts, plan replay and projection operations from the beginning, and avoid using the pattern where ordinary state storage would solve the real problem more simply.