CQRS

Command & Query Responsibility Segregation

Segregate read responsibility i.e. Query operations & command responsibility i.e. Command operations.

-> In most of the e-commerce websites read operations (search) are way more in number compared to write operations (item purchase).

-> Read operations may have complex queries.

Solution

Create a Product-Query-Microservice for READ operations (GET) & create a Product-Command-Microservice for WRITE operations (POST/PUT/DELETE). Now both the services will have their own DB, so to keep them in sync we'll need a message broker (Kafka/RabbitMQ). We can then trigger events, and subscribe to events.

Last updated