CQRS pattern - AWS Prescriptive Guidance

CQRS pattern

The command query responsibility segregation (CQRS) pattern separates the data mutation, or the command part of a system, from the query part. You can use the CQRS pattern to separate updates and queries if they have different requirements for throughput, latency, or consistency. The CQRS pattern splits the application into two parts: the command side and the query side. The command side handles create, update, and delete requests. The query side runs the query part by using the read replicas.

In the following illustration, a NoSQL data store, such as DynamoDB, is used to optimize the write throughput and provide flexible query capabilities. This achieves high write scalability on workloads that have well-defined access patterns when you add data. A relational database, such as Aurora, provides complex query functionality. A DynamoDB stream sends data to a Lambda function that updates the Aurora table.

        CQRS pattern diagram

You should consider using this pattern if:

  • You implemented the database-per-service pattern and want to join data from multiple microservices.

  • Your read and write workloads have separate requirements for scaling, latency, and consistency.

  • Eventual consistency is acceptable for the read queries.


The CQRS pattern typically results in eventual consistency between the data stores.