CQRS
CQRS
Command Query Responsibility Segregation
Split the Domain model into Read and Write model
Suggests the use of separate READ and WRITE Models for the realization of Collaborative domains
A Collaborative domain is one in which multiple actors invoke commands in parallel on the same data. E.g., online bidding, concert ticket reservations & trading systems
Why NOT use common model?
If same DB model is used on shared database instance:
- Loss of ability to optimize Reads & Writes
- Requires creation of multiple database indexes that impacts performance of writes
- Removal of indexes impact query performance
Benefits of Read/Write separation
- READ & WRITE models may use independent Datastores (Polyglot databases)
- READ | WRITE side may scale independently. E.g., a read heavy application may scale using:
- Read replicas
- Sharding
- Horizontal scaling
- READ | WRITE models may be managed by different teams which leads to agility & lower risk