Stackbook Logo
data-consistencyestablished · high operational burden

Event Sourcing

Also known as: event-store, event-sourced

Intent

Persist state changes as an immutable sequence of events, enabling complete audit trail, temporal queries, and rebuild of state.

Problem

Traditional CRUD loses history — you know current state but not how you got there. Auditing, debugging, and temporal queries are hard.

Forces

  • Business needs audit trail (who did what, when, why)
  • Need to query state at any point in time
  • Domain events are the language of the business
  • Rebuilding projections for new read models must be possible

Solution

✓ When to Use

  • Audit/regulatory requirements (financial, healthcare, gov)
  • Complex domain with rich business events
  • Need temporal queries (state at date X)
  • Multiple read models from same write model
  • Debugging: reproduce production state locally

✗ When Not to Use

  • Simple CRUD with no audit needs
  • High-throughput, low-latency writes (event store adds overhead)
  • Team unfamiliar with event-driven thinking
  • Schema evolution complexity not justified

Pros

  • +Complete audit trail by default
  • +Temporal queries: state at any point
  • +New projections without data migration
  • +Event replay for debugging, testing, migration
  • +Domain events align with business language

Cons

  • Event schema evolution is hard (upcasters, migrations)
  • Eventual consistency between write and read models
  • Storage grows unbounded (snapshots, retention policies)
  • Querying current state requires replay (mitigate: snapshots)
  • Learning curve: shifts thinking from state to events

Cost Profile

Infrastructure

Medium — event store (EventStoreDB, Kafka, custom)

Operational

High — monitor lag, schema evolution, replay

Cognitive

High — event modeling, projection design

Failure Modes

  • Event schema breaking change corrupts projections

  • Projection lag → stale reads

  • Snapshot corruption → full replay needed

  • Event ordering violations across partitions

Real-World Examples

Alternatives

  • audit-log
  • cdc
  • outbox-pattern
  • traditional-crud

Related Patterns

  • cdc
  • outbox-pattern
  • saga-pattern
  • cqrs

Competency Domains

data statereliability opssecurity complianceeconomics evolution