CQRS

162 단어·1 분·원문(.md)

CQRS is a concept that should be understood alongside Event Sourcing.

Simply put, it separates the responsibilities of Commands (Create, Update, Delete) and Queries (Read).

When considered in conjunction with Event Sourcing, events only occur when a Command, i.e., a state change, happens, and only those cases need to be recorded.

Since simple Queries do not change the model's information, separating their functionality makes it easier to apply the Event Sourcing Pattern.

Furthermore, the latest data (snapshot) generated by the Event Sourcing concept can be accessed and queried as a Query in CQRS, which simplifies logic and easily improves query speed through caching.

Advantages #

  • It offers data processing advantages in microservices. Data can only be modified through specific APIs, and read operations are separated to be performed using query APIs.
  • Performance can be improved by separating read/write requests.
  • Data anomalies are easier to find than with a simultaneous write approach.
  • When used with Event Sourcing, operations can be performed asynchronously.
MSA/pattern/cqrs.md