Skip to Content

Command Query Responsibility Segregation — split reads and writes onto different models or even different databases.

Data Flow

Writes: client -> Command -> Write DB (normalised OLTP)
                                              |
                                              v (event / change feed)
Reads:  client -> Query  -> Read DB (denormalised, optimised for search)

When to use

Pitfalls

Analogy

A library: the librarian files new books immediately (write model) but a separate index/ catalogue (read model) is updated periodically for fast search.

Interview tip: State the consistency lag bound (sub-second? minutes?) so the interviewer knows the trade-off.

Advertisement