Topic 105 / Core
Synchronous and asynchronous communication
Chapter 7.1 · Asynchronous Foundations
What and why
A caller needing work done by another component has exactly two shapes to choose from. Synchronous communication blocks the caller until the response arrives — tight coupling in time. Asynchronous communication hands the work off and lets the caller continue; any answer, if one exists, arrives later through a callback, a poll, or a separate event. A third shape, asynchronous request–reply, sends the request on an async transport (a queue, tagged with a correlation ID) but still delivers an answer back on a reply channel — async plumbing with a synchronous-feeling contract. Builds on: → 10 (client–server architecture).
Diagram
| Synchronous | Asynchronous | |
|---|---|---|
| Caller blocks? | Yes, until response or timeout | No |
| Coupling | Caller and callee must both be up now | Decoupled in time |
| Failure visibility | Immediate | Can be silent until something checks |
| Typical use | Needs the answer to proceed | Work can finish later |
How it works
- The caller decides whether it needs the result before it can do anything else.
- Synchronous: open the request, block, wait for a response or a timeout.
- Asynchronous: hand the work to a queue, message, or event, and return immediately; the result (if any) is obtained later by callback, polling, or a separate notification.
- Asynchronous request–reply: the caller sends a request carrying a correlation ID into a request channel, then waits on (or polls, or is notified on) a reply channel tagged with that same ID.
- The choice changes failure handling: a synchronous failure is immediate and visible; an asynchronous one can go unnoticed until queue depth or a dead-letter queue (→ 117) is checked.
Practical example
(illustrative). A checkout flow calls payment authorization, then triggers a receipt email. Payment stays synchronous — the user needs to know now whether the card was charged, inside a roughly 2-second latency budget. The receipt email is published to a queue and the checkout request returns immediately; the email send, which might otherwise add 300 ms to the critical path, happens after the response is already on its way to the user.
When to use it
- Use synchronous when the caller needs the answer to proceed or to display it — card authorization, input validation.
- Use asynchronous when the work doesn't block the user and can finish after the response returns — search indexing, email, thumbnail generation.
- Avoid synchronous when the callee is slow or unreliable and the caller would rather fail fast or degrade (→ 97 admission control; → 151 circuit breaker). Avoid asynchronous when the caller's own logic cannot proceed without the result — that case wants async request–reply, not fire-and-forget.
- Failure scenarios: synchronous — a blocked caller and a slow callee cascade into a wider outage (→ 152 retries and backoff feed this). Asynchronous — a lost or stuck message looks, from the caller's side, exactly like success.
- Simpler alternative: stay synchronous until a measured reason (latency, load, an unreliable dependency) justifies paying for decoupling — async buys resilience to spikes at the cost of eventual consistency and harder debugging.
Practice
(decision — judge scenarios and defend the choice; 15–20 min, no lab service required). For five interactions — place an order, send a welcome email, charge a card, generate a recommendation feed, log a user out — decide synchronous, asynchronous fire-and-forget, or asynchronous request–reply, and name the consistency and latency trade-off each choice accepts. Done when every choice names that trade-off, not just the mechanism.
Key takeaway
Synchronous trades latency for certainty now; asynchronous trades certainty-now for decoupling and resilience to spikes. Done when you can: label any two-service interaction as sync, async fire-and-forget, or async request–reply, and defend it. Used next in → 106 (message queues, the usual asynchronous transport).
References
None — this topic makes no external claims.
Source directory