liveBook · Manning

Command-side replica

As explained in Microservices Patterns, Second Edition

A command-side replica is a service collaboration pattern that maintains replicated data to support distributed command processing.

A command-side replica maintains a local, read-only copy of data from another service so a command can query it efficiently. It is a service collaboration pattern for distributed commands: operations that span multiple services. section 7.6.2

Distributed operations cross process and transaction boundaries, making them more complicated than local operations. With eventual consistency, they require careful design: database locking and rollback cannot coordinate the whole operation, and concurrency must be handled at the application level. section 7.5.1

Choose the collaboration pattern for the operation’s job:

  • Use a command-side replica when a command needs to query data owned by another service. Use a saga to implement a distributed command as a series of local transactions. section 7.6.2
  • For distributed queries, API composition queries services and aggregates their results; CQRS maintains a read-only, efficiently queryable replica combining data from multiple services. section 7.6.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines the pattern and contrasts collaboration patterns, while deferring implementation details.
What you can do after
Evaluate collaboration patterns by distinguishing command-side replicas from sagas and distributed-query patterns.
How it connects
Connects distributed commands to saga and distinguishes distributed queries using API composition and CQRS.

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.