Skip to content
StackDecode
System Design
9. Message Queues and Event-Driven Systems11. Microservices ArchitectureAnimated

Event Sourcing

Store changes as events instead of current state.

The idea

State is rebuilt by replaying events, giving a full audit trail.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

CommandAggregateEvent storeProjectionRead view
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Never overwrite state; record what happened as events.

step:
1/4
at:
Command
1/9

The green dot is a request moving through the system.

Step by step

  1. 1Record each change as an event
  2. 2Append to the log
  3. 3Rebuild state by replay
  4. 4Snapshots speed this up

Where it is used

Auditable systems.

Watch out for

Event schemas must evolve carefully.

Related