liveBook · Manning

Distributed command

As explained in Microservices Patterns, Second Edition

A command whose data updates span multiple services.

A distributed command updates data in multiple services. Because services are separate process and transaction boundaries, coordinating the operation is harder than a local transaction. A common approach is to sequence local ACID transactions rather than use a distributed transaction. section 9.0 section 7.5.1

Eventual consistency trades strong, immediate consistency for availability:

  • Services can respond while another service is unavailable. section 7.5.1
  • The application must manage inconsistency, undo committed changes when needed, and handle concurrency; distributed queries cannot provide a strongly consistent cross-service view. section 7.5.1
  • Saga and command-side replica are patterns for implementing distributed commands. section 7.5.1

Order creation and credit reservation

The Order Service can persist an order before the Consumer Service reserves the customer’s credit. If the Consumer Service is unavailable, the order request can still receive a response, but the operation requires careful coordination. section 7.5.1

Figure 7.9 Distributed transactions are replaced with a sequence of local transactions coordinated by asynchronous messaging
2PC BASE

The figure illustrates replacing a distributed transaction with local transactions coordinated through asynchronous messaging. section 7.5.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains transactional challenges, eventual consistency, and application-level trade-offs without detailing a specific implementation.
Examples
Uses order persistence followed by customer credit reservation to illustrate cross-service updates.
What you can do after
Understand the availability benefits and consistency, concurrency, and rollback costs of coordinating cross-service updates.
How it connects
Connects eventual consistency with Saga, command-side replica, ACID transactions, and two-phase commit.

Related concepts

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.