Architecture PatternsExpert15 min read2 questions

Event-Driven Architecture, CQRS and Event Sourcing

Three related patterns that are constantly conflated. What each actually gives you, what each costs, and why event sourcing is far more expensive than it looks.

Covers: Events vs commands, event-carried state transfer, CQRS read models, event sourcing, projections, replay and versioning

Event-driven architecture, CQRS and event sourcing are three separate decisions. You can do any one without the others, and conflating them is the most common way candidates get into trouble here - usually by proposing event sourcing when all they needed was an event.

Filter
0/2 mastered
AdvancedeventsedamessagingAsked at Amazon, Monzo

30-second answer

A command is an instruction to a specific handler to do something, named imperatively - `ChargePayment` - and it can be rejected. An event is a statement that something already happened, named in the past tense - `PaymentCharged` - and cannot be rejected because it is history. Commands have one intended handler; events have zero or many subscribers. On content, prefer events that carry enough state for common consumers to act without calling back, but include the entity ID and a version so a consumer that needs more can fetch it.

Expertcqrsevent sourcingarchitectureAsked at Monzo, Stripe

30-second answer

CQRS separates the write model from the read model so each can be optimised independently - normalised and validated for writes, denormalised and query-shaped for reads, kept in sync asynchronously. It is worth it when read and write workloads differ dramatically in shape or volume. Event sourcing goes further: the immutable event log becomes the source of truth and current state is a projection of it, giving a perfect audit trail and the ability to rebuild any view or answer historical questions. It is worth it in genuinely event-shaped domains - finance, ledgers, order lifecycles - and is usually a mistake elsewhere, because you inherit schema versioning, replay cost, snapshotting and the loss of simple ad-hoc queries.

Showing 2 of 2 questions for event-driven-architecture-cqrs-and-event-sourcing.

Check your understanding

4 questions · no sign-up, nothing stored

0/4 answered
Question 1

1.Which is correctly named as an event?

Question 2

2.What is the main practical benefit of CQRS?

Question 3

3.Which is the strongest case for event sourcing?

Question 4

4.Why do event-sourced systems need snapshots?

Hands-on challenge

Build it - this is what you talk about in a deep-dive round.

Model an order lifecycle as events

Design the event model for an order that can be placed, paid, partially shipped, partially refunded and cancelled.

Requirements

  • List every event with its past-tense name and payload, including the envelope fields.
  • Show how current order state is derived by folding the event stream.
  • Design two projections with different shapes and show that both are rebuildable.
  • Define a snapshot strategy and justify the interval.
  • Describe how you would add a new field to an event consumed by three teams.

Stretch goals

  • Handle a GDPR erasure request against the immutable log.
  • Design the repair process for a bug that emitted incorrect events for a week.