Systems & Backend

CQRS

also: command query responsibility segregation

Separate the write model from the read model, optimizing each independently.

CQRS (Command Query Responsibility Segregation) splits a system into a write side (commands that change state) and a read side (queries that return data), each with its own model and often its own datastore. This lets you optimize reads and writes independently instead of forcing one model to serve both.

Worked example: writes go through a normalized, validated command model; a separate denormalized read model (updated from the write side’s events) serves fast queries — so a complex dashboard reads a purpose-built projection instead of joining the transactional tables. Gotcha: CQRS adds complexity and usually eventual consistency (the read side lags the write side), so it is overkill for simple CRUD — reach for it only where read and write workloads genuinely diverge, commonly alongside event sourcing.