CQRS
Command Query Responsibility Segregation is an architectural pattern that splits a system's write path (commands that change state) from its read path (queries that return state) — typically with separate models, sometimes separate databases. CQRS scales reads and writes independently and lets each side be optimised for its workload.
CQRS was named by Greg Young around 2010, extending Bertrand Meyer's command-query separation principle from object design to system architecture. It pays off when read patterns and write patterns diverge sharply — e.g., a write model needs strong consistency and complex validation while reads need denormalised, queryable projections. CQRS often (not always) pairs with event sourcing: the write side appends events, projectors build read models. Anti-pattern: applying CQRS to a CRUD system that has neither read-write divergence nor scale — you pay the complexity cost without the benefit. Common rule of thumb: introduce CQRS at the service or bounded-context level, not system-wide.
Related terms
- Event sourcing
Event sourcing is a persistence pattern that stores every state change as an immutable event in an append-only log.
- Domain-driven design
Domain-driven design (DDD) is a software-design approach, formalised by Eric Evans in 2003, that places the business domain at the centre of model design.
- Saga pattern
A saga is a sequence of local transactions across multiple services that together accomplish a distributed business transaction.