Skip to main content

CQRS (Command Query Responsibility Segregation) Pattern

Learn CQRS (Command Query Responsibility Segregation) Pattern (Core Microservices Patterns, Microservices Design Patterns) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is CQRS? CQRS separates the model used to WRITE data (Commands - "place this order," "update this profile") from the model used to READ data (Queries - "show me this order's status"), instead of using one single model for both. Why Separate Them? • Read and write workloads often have very different needs - reads are usually much more frequent and can tolerate slightly-stale data; writes need strict consistency. • The optimal data shape for writing (normalized, transactional) is often NOT the optimal shape for reading (denormalized, pre-joined, fast to query). • They can be scaled...

More lessons in Core Microservices Patterns