Skip to content
ADevGuide Logo ADevGuide
Go back

Synchronous vs Asynchronous Communication: Trade-offs and Examples

By Pratik Bhuite | 14 min read

Hub: Java / Interview Fundamentals

Series: Backend Interview Mastery

Last verified: Sep 19, 2026

Part 40 of 88 in the Backend Interview Mastery

Key Takeaways

On this page
Reading Comfort:

Synchronous and asynchronous communication compare request-response with queued work

When a checkout request waits for inventory, payment, email, and analytics before returning, one slow dependency becomes the user’s problem. When the same request accepts an order and publishes work for later, the user gets a quick response but the system must now handle queues, retries, status, and eventual consistency.

This synchronous vs asynchronous communication guide explains the boundary in distributed backends, how to choose it, and which reliability obligations move when a call becomes a message. Continue with Kafka vs RabbitMQ, queue vs pub/sub, and the Backend Interview Mastery series.

Table of Contents

Open Table of Contents

The Short Answer

Use synchronous communication when the caller needs a decision before it can continue: validation, authorization, a read query, or a small command with an immediate result. Use asynchronous communication when work can be accepted first and completed later: image processing, email delivery, analytics, retries, and traffic smoothing.

The decision is not about whether the client library uses an async keyword. It is about the distributed contract. A synchronous HTTP request blocks the business flow on a response; an asynchronous message hands work to a durable intermediary and returns an acceptance or job identifier.

RequirementStronger defaultWhy
User needs a value nowSynchronousThe response is part of the request contract
Long-running or bursty workAsynchronousA queue absorbs work and workers scale independently
Immediate validation or permissionSynchronousReject before accepting side effects
Email, indexing, thumbnails, analyticsAsynchronousFailure can be retried without blocking the user
Cross-service workflow with a durable historyAsynchronousEvents and commands survive process restarts
Tiny read with a strict freshness requirementSynchronousExtra queue latency would add complexity without value

What Synchronous Communication Means

In a synchronous interaction, the caller sends a request and keeps the business operation open until it receives a response, timeout, or error. HTTP, gRPC, and a database query can all be synchronous at the architecture boundary even if the implementation uses non-blocking threads.

flowchart TD
    A[Client request] --> B[API service]
    B --> C[Inventory service]
    C --> D[Response]
    D --> B
    B --> E[Client receives result]
    C -->|Timeout or error| F[Fallback or failure]

The advantage is a simple mental model: the caller knows whether the operation succeeded and can show a result immediately. The cost is coupling. Every dependency consumes part of the caller’s deadline, and a slow or unavailable downstream service consumes threads, connections, and user patience. The total deadline should be budgeted across hops rather than copied independently at every service.

What Asynchronous Communication Means

In an asynchronous interaction, the producer completes its local responsibility after a broker or durable store accepts the work. A consumer processes the message later and reports completion through an event, status endpoint, notification, or workflow record.

flowchart TD
    A[Client request] --> B[Order service]
    B --> C[(Order database)]
    B --> D[Outbox event]
    D --> E[Message broker]
    E --> F[Inventory worker]
    E --> G[Email worker]
    F --> H[Status event]
    H --> I[Status API or webhook]

Asynchronous communication improves isolation and burst handling, but it does not remove waiting; it changes where waiting happens. The caller now needs a durable status model, correlation ID, retry policy, duplicate handling, and a clear definition of accepted versus completed. A queue is not automatically durable, ordered, or exactly once: those are separate choices covered by Kafka delivery guarantees.

Choosing the Boundary

Ask four questions before selecting a protocol:

  1. Does the caller need the result to make its next decision? Keep that part synchronous.
  2. Can the work be retried without a human waiting? An asynchronous boundary is a candidate.
  3. What is the failure contract? Decide whether the user sees failure, pending, or a compensating state.
  4. Where is the source of truth? Store acceptance and progress durably before returning from an async command.

Most production designs are hybrid. An API synchronously validates a request, writes an order and outbox record, then asynchronously charges a payment provider and sends notifications. Keep the synchronous portion small and deterministic; push expensive, retryable, or fan-out work behind a durable boundary.

Reliability and Failure Handling

Synchronous calls need deadlines, cancellation, bounded retries, idempotency for non-read operations, and circuit breakers for unhealthy dependencies. Retrying a timed-out payment without an idempotency key can create a duplicate charge because the provider may have completed the first attempt before the client saw the timeout.

Async workflows need different controls:

  • Durability: acknowledge only after the broker or outbox write is safe.
  • At-least-once reality: handlers must be idempotent because redelivery is normal.
  • Backpressure: bound queue depth, worker concurrency, and downstream rate.
  • Observability: carry a correlation ID and measure age, retries, and completion time.
  • Recovery: use a dead-letter or reconciliation path after the retry budget expires.

The dead-letter queue guide shows why a failed consumer should preserve the original event and failure context instead of silently dropping work.

Capacity and Latency Example

Suppose checkout receives 500 requests per second and payment takes 400 ms at the 95th percentile. A synchronous design keeps roughly 500 * 0.4 = 200 payment calls in flight before adding network and retry overhead. If payment slows to two seconds, the in-flight population rises to about 1,000 and can exhaust connection pools.

An asynchronous design writes the order and queues payment work quickly, then runs 250 workers at an average 100 ms of local handling time. The queue absorbs bursts, but the product must show PAYMENT_PENDING, expose status, and decide how long an unpaid order remains reservable. Capacity moves from request threads to workers; it does not disappear.

Production Implementation

async function createOrder(input: CreateOrderInput) {
  const order = await db.transaction(async tx => {
    const saved = await tx.orders.insert({
      status: "PAYMENT_PENDING",
      ...input,
    });
    // The outbox shares the transaction, so a committed order cannot lose its event.
    await tx.outbox.insert({ type: "OrderCreated", aggregateId: saved.id });
    return saved;
  });

  // A publisher retries this record independently of the request lifecycle.
  return { orderId: order.id, status: order.status };
}

The API is synchronous about acceptance, while payment is asynchronous. The transaction prevents the classic dual-write failure where the order commits but the event does not. A status endpoint or webhook makes eventual completion explicit instead of pretending that 202 Accepted means payment succeeded.

Interview Questions

1. Is asynchronous communication always faster?

No. It often returns an acceptance response faster because the caller does not wait for all downstream work, but total completion can take longer. Queues add broker and scheduling latency, and a backlog can increase end-to-end age. Compare user-visible acknowledgment latency with business completion latency.

2. Why not make every microservice call asynchronous?

Some decisions need an immediate answer, such as authorization or inventory availability. Turning them into messages creates a state machine, delayed errors, and a status contract that may be harder than the original call. Use asynchronous boundaries where decoupling, retries, or burst absorption pays for that complexity.

3. How do you make an asynchronous handler safe to retry?

Give each command or event a stable ID, store a deduplication or inbox record with the side effect, and make the state transition conditional on the expected version. A handler should acknowledge only after the effect and its idempotency record are durable. This makes a crash between the effect and acknowledgement recoverable.

4. What does 202 Accepted mean?

It means the server accepted the request for processing; it does not mean the business operation completed successfully. Return a job or aggregate ID, document a status resource or callback, and define expiration and failure states. If the operation is small and must succeed before the response, use a synchronous contract instead.

5. How do timeouts differ between sync and async designs?

Synchronous calls need a request deadline propagated across the call chain so resources are released when the caller no longer cares. Asynchronous work needs a processing deadline, visibility timeout, retry budget, and possibly a business expiration time. A queue can wait longer, but it still needs a policy for stale work.

Conclusion

Synchronous communication buys an immediate answer and a simple control flow at the cost of coupling to downstream latency. Asynchronous communication buys buffering, independent scaling, and durable retries at the cost of eventual consistency and a richer operational contract. Strong backend designs use both: validate and record what must be immediate, then queue work that can complete safely later.

References

  1. AWS: What is a Message Queue?
  2. Microsoft: Asynchronous messaging options
  3. Enterprise Integration Patterns: Messaging

YouTube Videos

  1. “Synchronous vs Asynchronous Architecture - No Silver Bullet” - Three Dots Labs [https://www.youtube.com/watch?v=SRjTQCDpXVo]

Share this post on:

Next in Series

Continue through the [object Object] with the next recommended article.

Related Posts

Keep Learning with New Posts

Subscribe through RSS and follow the project to get new series updates.

Was this guide helpful?

Share detailed feedback

Previous Post
Service Discovery: DNS, Registries and Kubernetes Services
Next Post
Kafka vs RabbitMQ: Differences, Trade-offs and When to Use Each