← Lessons

quiz vs the machine

Gold1420

System Design

The Event Store Design

What an append only event database needs to guarantee for sourcing to work.

5 min read · core · beat Gold to climb

Purpose built storage

An event store is a database designed to hold immutable events as the source of truth. It is organized around streams, where each stream is the ordered history of one entity such as one account.

Core guarantees

  • Append only writes, never update or delete within a stream.
  • Ordering within a stream so replay is deterministic.
  • Optimistic concurrency using an expected version number to reject conflicting writes.

Reading patterns

  • Read one stream forward to rebuild an entity.
  • Subscribe to all events to feed projections and other consumers.
  • Many stores expose a global position so subscribers can resume exactly where they stopped.

Concurrency in practice

When two writers act on the same entity, the store accepts the first and rejects the second because its expected version no longer matches. The loser retries on fresh state. This keeps each stream internally consistent without locks held across the network.

Key idea

An event store provides ordered append only streams with version based concurrency so entity history is durable and replay is deterministic.

Check yourself

Answer to earn rating on the learn ladder.

1. How does an event store typically prevent conflicting writes?

2. What is a stream in an event store?