What it is
In synchronous communication the caller sends a request and waits for the answer before it continues: an HTTP or gRPC call, a database query. In asynchronous communication the caller hands the work to an intermediary (a queue, a topic, a log) and continues without waiting; someone else does the work later and the outcome is reported separately, if at all. The difference is temporal coupling: whether both sides have to be up, and fast, at the same moment.
Why it exists
Synchronous calls are simple: one code path, an immediate answer, errors returned to the caller. But in a chain of services, every call adds its latency and its failure probability to the caller’s request, and every waiting caller holds a thread, connection or worker. Asynchronous messaging exists to take work that does not have to finish now (emails, labels, indexing, analytics) off that path, so the user-facing request depends only on what it truly needs.
How it works
Latency adds up. In a chain A → B → C, A’s response time is its own work plus B’s full response time, which includes C’s, plus every network hop. In the lesson: 10 + 20 + 60 ms of work and six hops give a median of about 150 ms.
Slowness spreads upstream. A caller that waits holds a worker for as long as the callee takes. If C becomes eight times slower, B’s workers are busy eight times longer, B’s capacity collapses even though its code is fine, its queue fills, and A sees timeouts. Timeouts, bulkheads (separate pools per dependency) and circuit breakers limit this; they do not make the slow work faster.
Availability multiplies. If a request needs n independent services each available a, it succeeds with probability aⁿ: three services at 99.9% give about 99.7%, roughly three times the downtime of one. Real failures are often correlated (shared databases, deploys), which can make it worse.
A queue in between. The producer writes a message and answers once the broker has stored it. Consumers pull messages at their own pace and acknowledge them after processing. The request path no longer includes the work, so a slow or failed consumer shows up as backlog (queue depth, age of the oldest message) instead of user latency or errors. The queue absorbs differences in rate, but it does not add capacity: if consumers stay slower than producers, the backlog grows without bound until the queue’s limits are reached.
The asynchronous contract. The API answers 202 Accepted with an identifier and a way to learn the outcome: a status resource to poll, a webhook, a push notification. The result is eventually available, so the UI must show a pending state. Delivery is typically at-least-once, so consumers must be idempotent. Failures happen after the response and land in retries and a dead letter queue, so they need monitoring and a way back to the user.
When to use it
- Synchronous when the caller needs the result to continue: price and stock checks, payment authorisation, reads that render the page. Keep the chain short and give every call a timeout.
- Asynchronous for side effects that can finish after the response: notifications, shipping labels, search indexing, analytics, thumbnails, webhooks to third parties.
- Asynchronous to absorb bursts and to isolate a flaky or slow third-party API from user traffic.
When not to
- Don’t make a call asynchronous if the user must see its result immediately; you would only add polling and latency.
- Don’t queue work to hide a capacity problem: a permanently growing backlog is an outage in slow motion.
- Don’t introduce a broker for one simple call between two services you own when a timeout and a retry would do.
Trade-offs
| Synchronous | Asynchronous | |
|---|---|---|
| Caller latency | Includes all downstream work | Only up to the enqueue |
| Failure of a dependency | Caller fails or times out | Backlog grows; caller unaffected |
| Availability | Product of the chain | Producer and broker only |
| Result | Immediate, in the response | Later: polling, callback, event |
| Consistency | Done when the call returns | Eventually consistent |
| Errors | Returned to the caller | Retries, DLQ, separate alerting |
| Operations | Simple to trace | Broker to run, backlog to watch, duplicates to handle |
Alternatives
- Timeouts, retries with backoff, circuit breakers and bulkheads keep synchronous calls but bound the damage of a slow dependency.
- Publish/subscribe for one event with several independent consumers.
- Event streaming (a log such as Kafka) when consumers need ordering per key or replay.
- Transactional outbox to publish the message reliably in the same transaction as the database write.
- Caching or precomputing the dependency’s answer so the synchronous call is avoided.
Failure modes
- Cascading slowness: a slow synchronous dependency exhausts the workers of every caller above it.
- Retry storms: callers retry timeouts and multiply the load on the struggling dependency.
- Unbounded backlog: consumers fall behind permanently; messages age out or the queue fills and producers get errors.
- Lost work: the service commits its database write but crashes before publishing the message (use an outbox).
- Duplicates: at-least-once delivery processes the same message twice; non-idempotent consumers send two emails or two labels.
- Invisible failures: asynchronous errors never reach the user unless the status model and alerts surface them.
In production
Draw the synchronous path of each user request and keep it as short as possible; give every call a timeout below the caller’s own. Move side effects behind a queue, published through an outbox. Alert on queue depth and oldest-message age, not just consumer errors, and autoscale consumers on backlog. Make consumers idempotent (dedupe by message or business id). Expose a status resource for anything the user cares about, and send failed messages to a dead letter queue someone actually watches.
Common misconceptions
- "Async is faster." It makes the caller faster; the work itself takes as long, and often finishes later.
- "A queue adds capacity." It moves the wait from the user to the backlog; consumers still need to keep up on average.
- "If my service is healthy, a slow dependency is someone else’s problem." Your workers wait for it, so its slowness becomes yours.
- "Messages are delivered exactly once." Most brokers deliver at least once; exactly-once effects need idempotent consumers.
Interview angle
For each step of a flow, ask "does the caller need this result now?" and say it out loud. Interviewers look for: latency budgets along the synchronous path, the availability product, timeouts and circuit breakers on remaining sync calls, a queue (with an outbox) for side effects, 202 Accepted with a status endpoint, idempotent consumers, and backlog monitoring. Mentioning that a queue absorbs bursts but not sustained overload is a strong signal.
Model assumptions
The simulation is a simplified model, not a benchmark. Shoppers arrive as a Poisson stream at 50 checkouts per second and give up after 1 second. The Checkout API (64 workers, 10 ms), Orders service (16 workers, 20 ms, 40 waiting) and Label service (16 workers, 60 ms, 30 waiting) are servers with lognormal service times; each holds a worker while it waits for the service it calls. "Slow" multiplies a node’s service time by eight. In the asynchronous version the Orders service answers as soon as the Label queue has stored the message; Label workers (8 slots, 60 ms) consume and acknowledge messages, with a 10-second visibility timeout. The 202 Accepted reply and the status polling flow are scripted illustrations; the engine does not model status stores or polling. Availability figures in the text are arithmetic, not simulated. Numbers show behaviour and orders of magnitude only.