SteelReed

Search

Search posts, questions…

MicroservicesQuestion 10 / 24

Middle

What is CQRS, when is it worth it, and when is it overkill?

Short answer

CQRS splits the write model (commands; constraints, transactions) from the read model (queries; data pre-shaped for screens), kept in sync via events or CDC. It pays off when reads and writes have very different needs; for plain CRUD it doubles the complexity.

commandevents or CDCqueryClientWrite modelconstraints, transactionsRead modelpre-shaped for screens

3 points to say:

  1. Separate the write model (normalized, ACID) from the read model (denormalized, fast); event sourcing is not required.
  2. There are four levels, from separate classes on one DB to event sourcing; pick the lowest level that solves the problem.
  3. The cost: eventual consistency, syncing, debugging in two places; worth it when reads and writes are clearly lopsided, overkill for CRUD.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.