ZANE.C
About

Command and Query Responsibility Segregation (CQRS)

Command and Query Responsibility Segregation (CQRS)

Created on Jan 16, 2026, Last Updated on Jan 17, 2026, By a Developer

In most of applications, reading and writing data usually has different requirement, and typically there is no single type of database can satisfy both sides, when the scale goes up.

Command And Query


Command and Query Responsibility Segregation (CQRS) is a design pattern that handles reads and writes separately.

  • Command is an instruction to make changes in the system.
  • Query refers to reading data from the system, without side effects.

Data Store


The key of CQRS is that commands and queries hit different databases. And the databases not necessarily need to hold the data in the same format.

So the typical flow is:

  • Commands hit one database.
  • Data will be synced to another database synchronously or asynchronously, with or without applying transformation on top.
  • All Queries hit this database.

This pattern allows scaling reads and writes in different way. However, the drawback is pretty obvious, maintaining data consistency would be a huge challenge. The syncing part between two database become a single point

© 2024-present Zane Chen. All Rights Reserved.