Command Query Responsibility Segregation

less than 1 minute read

Command Service for DB Writes/Data Mutation

Query Service for DB Reads/Data Read Operations

Both have it own database so it needs to be kept synchronized

CQRS Synchronization

  • With Message Brokers between command and query service
    • need to ensure that both data read and write to a message queue happens as a transaction
    • via the transactional outbox pattern
  • Function as a Service

Drawbacks

  • CQRS can only guarantee Eventual Consistency
  • Overhead and Complexity

CQRS + Materialized Views

for complicated joins between 2 different tables in two different databases.

Create a third “Search Service

The Search service will already have the Materialized Views (with the pre calculated joined data) in its search DB

All DB’s updated via Messaging Queue