← Back to microservices patterns map
✂️
Microservices Pattern

CQRS

Separate write models from read models so each can optimize for its own workload.

data

Detailed Description

CQRS is useful when reads and writes have very different shapes or scale needs.

It often pairs with events so read models can be updated asynchronously.

Visual Diagram

CQRS inside a service
  WRITE SIDE (Commands)
    POST /orders  → CommandHandler
                  → validates business rules
                  → updates Write DB (normalized)
                  → emits OrderPlaced event

  READ SIDE (Queries)
    GET /orders   → QueryHandler
                  → Read DB (denormalized, fast)
                  → populated from events

Tradeoffs

Pros

Fast reads, independent scaling, clear write intent

Cons

More moving parts and eventual consistency

Examples: Event-sourced systems, denormalized read stores