Skip to content

Event Sourcing & CQRS — Notes#

Where you find this in the wild#

  • Banking ledgers, trading systems (regulatory replay).
  • Kafka Streams / Materialize.
  • Axon Framework (JVM), EventStoreDB.
  • Most CQRS systems in production are only CQRS — not event sourced.

Event schema rules#

  • Events are immutable facts in past tense (AccountOpened, OrderShipped).
  • Never delete; "delete" is a new event (AccountClosed).
  • Add fields only; don't remove or rename. Use upcasters for forward migration.
  • Encode in a stable format (Avro, Protobuf with schema registry).

Read model lag SLO#

  • Define one — typical 1-5 s in production.
  • Surface lag on dashboards; alert when > threshold.

Anti-patterns#

  • Putting commands in the event log ("UserClickedSubmit" — commands are wishes, events are facts).
  • Treating events as DTOs (they're domain facts; downstream views should not couple to them).
  • Replaying with code that has business-logic changes that depend on time-of-replay.

Refs#

  • Greg Young: "CQRS Documents" (free).
  • Vaughn Vernon: Implementing Domain-Driven Design.
  • Martin Kleppmann: Designing Data-Intensive Applications, ch. 11.
  • EventStoreDB docs.
  • "Event Sourcing You Are Doing It Wrong" — Martin Kleppmann talk.