A distributed operation is an application operation that spans multiple services and requires them to communicate. Unlike a local operation that can call classes within one transaction, it crosses process and transaction boundaries. Some operations will span services even when the most important ones are kept local. section 7.5.1
Designing across those boundaries introduces three recurring challenges:
- Network communication costs time and bandwidth. Assess its impact against the operation’s service level objective, rather than assuming that every network call is unacceptable. section 7.5.1
- Synchronous calls create runtime coupling. An unavailable service can affect its callers, increasing latency or causing failures to cascade. section 1.3.4
- Transaction boundaries complicate consistency across services. Distributed operations may need to use eventual consistency instead of a single local transaction. section 1.3.4 section 7.5.1
Creating an order
A createOrder() operation can span an Order Service and a Customer Service. Its design must account for the Customer Service being unavailable and for the cost and failure modes of communication between services. section 1.3.4
Figure 7.9 Distributed transactions are replaced with a sequence of local transactions coordinated by asynchronous messaging
A sequence of local transactions coordinated by asynchronous messaging is one way to structure work across transaction boundaries. section 7.5.1
Use operation requirements when drawing service boundaries. Keeping an operation local can avoid distribution costs, but may trade away benefits such as team autonomy. Conversely, splitting services without managing their coupling risks a distributed monolith. section 7.2 section 7.5.1 section 7.7
