Command and Query Responsibility Segregation

Breaking the CRUD

CRUD works for limited business logic operations

CRUD can

  • lead to potentially unnecessary updates for certain operations
  • affect performance : prevents concurrent updates and implies load of excessive data
  • bring security and permission management overhead

CQRS => Separation of concern

Two separate data models:

Query Models read data from store

Command Models write data to store

Allows scaling of read ad write independently

CQRS => risky complexity

Use only in bounded context (limited sections of the system)

Dealing with resiliency and eventual consistency with event sourcing :

  • the store of event as a write model
  • materialised views as the read-only cache of data 

Related Patterns :

  • Data Consistency Primer
  • Data Partitioning Guidance
  • Event Sourcing Pattern
  • Materialized View Pattern

 

Made with Slides.com