Inter-Service Communication
The communication decision tree: synchronous vs asynchronous, one-to-one vs one-to-many, and the trade-offs of each.
Two axes of communication
Every inter-service interaction can be classified along two axes: synchronous vs asynchronous, and one-to-one vs one-to-many.
- Sync + one-to-one → request/response (REST, gRPC): caller blocks awaiting the answer.
- Async + one-to-one → command message via a queue: 'do this eventually'.
- Async + one-to-many → publish/subscribe events: 'this happened', consumers unknown.
Synchronous: simple but coupling
Request/response is intuitive and gives immediate answers, but it creates temporal coupling: both services must be up at the same moment. Chains of sync calls multiply this fragility — the availability of a chain is the product of each link's availability.
Five services at 99.9% each in a synchronous chain yield roughly 99.5% combined — from ~9 hours of downtime per year to ~44 hours.
Asynchronous: resilient but eventual
With a message broker between services, the sender doesn't wait and the receiver doesn't need to be up. Load spikes are absorbed by the queue, and consumers process at their own pace.
The cost: eventual consistency (readers may see stale data), harder debugging (no single call stack), and the broker itself becomes critical infrastructure.
Choosing wisely
A practical rule of thumb: use synchronous calls for queries the user is actively waiting on, and asynchronous events for state changes that other services react to.
Also decide your data-fetch strategy: query other services live (simple, but adds runtime coupling) or maintain a local replica updated by their events (resilient and fast, but eventually consistent). Mature architectures use both deliberately.
Key takeaways
- Classify interactions: sync/async × one-to-one/one-to-many.
- Synchronous chains multiply fragility — availability is the product of every link.
- Async messaging decouples in time and absorbs load spikes, at the cost of eventual consistency.
- Heuristic: sync for user-facing queries, async events for state propagation.
Knowledge check
Five services, each 99.9% available, are chained synchronously. Roughly what is the end-to-end availability?
Which interaction style fits 'notify all interested services that an order shipped'?
Checkout calls Inventory synchronously; Inventory's deploy causes 30s of downtime and checkout errors spike. What pattern would have prevented user-facing failures?