Microservice Patterns
Synchronous vs Asynchronous Communication
Calling services one after another couples their availability and latency; publishing events decouples them. See when each style fits — and what asynchrony costs.
What you will learn
- Explain how availability multiplies along a synchronous call chain.
- Compare latency and failure behaviour of request/response and events.
- Decide which steps of a workflow must be synchronous.
- Recognise the costs of async: eventual consistency, harder debugging, broker operations.
Overview
A phone call is synchronous: both people must be available at the same time, and you wait for the answer. A text message is asynchronous: you send it and carry on, and the other person replies when they can. Services talk to each other in the same two ways.
In synchronous communication (HTTP, gRPC) the caller sends a request and blocks until the response arrives. In asynchronous communication the caller publishes a message or event to a broker and continues; the receivers process it later, independently.
The problem with long synchronous chains
If placing an order calls Inventory, Payment and Notification in sequence, the order succeeds only if all three are up at the same moment. With 99.9% availability each, the chain has 99.9%³ ≈ 99.7%. Latencies add up too, and the slowest step decides the user's wait. This is temporal coupling.
Run it: the same order flow, two styles
Notification goes down from t = 10 s to t = 25 s in both scenarios. In A every order fails during the outage. In B ordering continues and the notifications wait in a backlog until the service is back.
Which style for which step?
| Use synchronous when… | Use asynchronous when… |
|---|---|
| The caller needs the answer to continue (price, stock check, authorisation). | The caller only needs to know the work will happen (send email, update analytics). |
| The user is waiting and the step is fast and reliable. | The work is slow, bursty or depends on flaky systems. |
| Strong consistency is required right now. | Eventual consistency is acceptable. |
Most real flows mix both: validate and reserve synchronously, then publish an event for everything that can happen afterwards.
Implementation sketch
@Transactional
public OrderId placeOrder(PlaceOrder command) {
// Synchronous: the customer needs to know now whether the items are available.
inventoryClient.reserve(command.items());
Order order = orders.save(Order.place(command));
// Asynchronous: payment capture, notification and analytics react on their own time.
// Written to the outbox in the same transaction (see Transactional Outbox).
outbox.save(OutboxEvent.of("Order", order.id(), "OrderPlaced", OrderPlaced.from(order)));
return order.id();
}Trade-offs
| Benefits | Costs | |
|---|---|---|
| Availability | Async: the producer works even when consumers are down. | Async: the broker becomes critical infrastructure. |
| Latency | Async: the user waits only for the essential steps. | Async: results arrive later; the UI must show "processing". |
| Simplicity | Sync: easy to read, debug and test. | Async: flows are spread across services; you need tracing and idempotent consumers. |
| Consistency | Sync: the caller knows the outcome immediately. | Async: data across services is eventually consistent. |
Production considerations
- Publish events reliably with a Transactional Outbox and process them with idempotent consumers.
- Keep synchronous chains short (ideally one hop from the edge) and protect every hop with timeouts and circuit breakers.
- Monitor consumer backlogs: in async systems an outage shows up as growing lag, not as errors.