CQRS: Command Query Responsibility Segregation¶
Read and write operations have fundamentally different characteristics; separating them into distinct models allows each to be optimized independently without compromise.
Tension Addressed¶
Write Optimization vs. Read Optimization
Recognizable As¶
Separate read and write APIs, materialized views for queries, command handlers distinct from query handlers, eventual consistency between models
Canonical Sources¶
Meyer, "Object-Oriented Software Construction" (1988, CQS principle); Young, "CQRS Documents" (2010)
Transfers To¶
API design (read vs. write endpoints), caching architectures, reporting systems, any system with asymmetric read/write loads
CQRS acknowledges that trying to serve both reads and writes from a single model forces compromises in both. The cost is maintaining consistency between models.
Related Concepts¶
- Eventual Consistency - Distributed Patterns