Close

CQRS

The CQRS pattern is related to the Database Per Service pattern. CQRS stands for Command Query Responsibility Segregation. What’s the deal? The fine-grained nature of APIs provided by microservices is often different than what a client needs. It’s not desirable that clients need to interact with multiple services to get the data they need. This is especially true for mobile clients where you want to limit the number of database roundtrips for performance reasons.

With CQRS A separate view database is created and used as a read-only replica to query the data. The database contains multiple denormalized views that are scalable and performant. The database is kept up to data by subscribing to Domain events published by the service that own the data.

An alternative to CQRS is API Composition. Here one endpoint is called with an in-memory join of the query results from multiple services. API Composition is often implemented via the API Gateway pattern (read Azure API Management).

Source: Pattern Language for Micro Services