Command Query Responsibility Segregation is a pattern that splits read and write operations into separate models to optimize performance and scalability.
In complex systems, read and write operations often have different performance needs and data shapes. CQRS allows systems to scale and evolve each side independently. Especially useful in event-driven or microservice architectures.
Use CQRS when reads and writes are high-volume, have different scaling requirements, or involve complex logic.
You need to know
Commands and Queries are handled separately: Commands change data (Create, Update, Delete), Queries read data. Each can have its own model and storage.
Optimized for performance and maintainability: Read models can be denormalized for speed; write models enforce consistency and validations.
Often used with Event Sourcing: Write operations generate events, which are later used to build or update read views asynchronously.
Popular technologies
Axon Framework - Java-based toolkit for implementing CQRS and Event Sourcing.
EventStoreDB - A database optimized for Event Sourcing, often used with CQRS.
Azure Cosmos DB with Azure Functions - Often used to build serverless CQRS systems with separate read/write paths.
Like posts like this?
Every week, you'll get a new system design concept, broken down like this one.
Free subscribers also get a little bonus:
🎁 The System Design Interview Preparation Cheat Sheet
If you're into visuals, paid subscribers unlock:
→ My Excalidraw system design template – so you have somewhere to start
→ My Excalidraw component library – used in the diagram of this issue
No pressure though. Your support helps me keep writing, and I appreciate it more than you know ❤️