Q5 · How do you choose between synchronous and asynchronous communication?
Back to 24 Architecture Questions.
The question is not “which is faster”. The axis it turns on: what the caller can do while it waits, and who owns the failure when nobody is waiting. Sync couples the outcome to a present owner. Async frees the caller and simultaneously creates a failure that arrives when its owner has already left.
What the answer should contain
The caller’s time is the first question. If the caller can do nothing useful until the answer arrives (an authorization check, the stock level at checkout), the wait is inherent: sync. If the caller can proceed without it (receipt generation, analytics events, email), the wait is artificial: async. Choosing per interaction, not per system, is the core skill; most services legitimately use both.
Sync couples failure to a present owner. The caller is standing there when the error arrives, so handling is immediate and explicit: retry, compensate, show the user. The price is paid in blocked capacity, in timeouts, and in load coupling: the dependency’s slowness becomes your slowness, because your workers wait on it.
Async decouples time and failure at once. The queue absorbs both load and waiting. The price is that when the work fails, nobody is waiting: ownership must be assigned in advance by policy. Retries with a cap, backoff, a dead-letter queue, an alarm on queue depth. “Fire and forget” is not async design; it is failure denial.
Consistency shifts with the choice. Sync preserves a shared view of this moment (“yes, reserved”). Async accepts staleness and convergence. This is a business call: whether “reserved, probably” is something the product can sell.
Async moves the hard problems to the consumer. At-least-once delivery brings duplicates and ordering: consumers become idempotent, ordering becomes a design statement (a FIFO per key, a partitioned stream), not an accident.
Ideas worth mentioning out loud
- “Sync: the failure has an owner because someone is standing there. Async: the owner must be named before the first failure. Choose by asking who will be standing there.”
- A queue converts a latency problem into a backlog problem. You still have to solve the backlog.
- Choosing async to avoid designing failure handling gets it exactly backwards: async is more failure design, not less.
Follow-ups to expect
- What about user-facing latency? The sync path inherits the slowest dependency; the async path costs only an enqueue. That is the argument for async on any non-critical step of a request path.
- When is sync mandatory? When continuing on unconfirmed state corrupts the system: reservations, authorizations, payments.
- Doesn’t async lose ordering? Only if undeclared. A FIFO per key or a partitioned stream gives ordering as a contract.
Red flags in an answer
- “Fire and forget” with no DLQ and no retry policy.
- Async chosen to hide a dependency’s failures rather than own them.
- One mode for every interaction in the system.
- The queue treated as a reliability feature by itself, with nothing behind it.
Sources
- Pattern: Messaging, Chris Richardson, microservices.io: the asynchronous side of the choice, including the at-least-once consequences that make the failure policy mandatory rather than optional.
- Timeouts, retries, and backoff with jitter, AWS Builders’ Library: the sync side’s failure bill. Retries against a struggling dependency are how a queue-shaped problem gets answered with a retry storm.