Synchronous vs Asynchronous Integration

Synchronous integration makes the caller wait for a response before continuing, while asynchronous integration lets the caller continue without waiting for the receiving system to finish. The choice affects coupling, latency, failure handling, and system throughput.

In a synchronous integration, service A sends a request to service B and waits for B's response. A typical Java backend implementation uses an HTTP client and handles the response in the same request flow. The caller therefore depends on B being reachable and responding within an acceptable time.

In an asynchronous integration, service A submits work and continues without waiting for the final processing result. A common approach is a message broker such as Kafka or RabbitMQ: A publishes an event or command, and B consumes it later. This separates the timing of the producer from the consumer.

Synchronous communication is useful when the caller immediately needs a result, such as fetching a customer's current account details. It is straightforward to reason about, but latency and failures in the downstream service can directly affect the caller.

Asynchronous communication is useful for work that can happen later, such as sending an email after an order is created. It can improve resilience and absorb traffic spikes through queues, but introduces concerns such as retries, duplicate messages, ordering, eventual consistency, and monitoring distributed workflows.

The distinction is about interaction timing, not whether HTTP or messaging is used exclusively. An HTTP request is commonly synchronous, while a message queue is commonly asynchronous, but either style can be implemented with different technologies.

Key points

Interview questions

What are the trade-offs of synchronous service-to-service calls?

Synchronous calls are relatively simple because the caller receives the result in the same flow and can make an immediate decision. However, downstream latency contributes to end-to-end latency, and downstream failures can prevent the caller from completing. Timeouts and carefully designed retry policies are therefore important. Too many synchronous dependencies can also create long chains of coupled services.

What is the difference between synchronous and asynchronous integration?

With synchronous integration, the caller sends a request and waits for a response before completing that part of its work. With asynchronous integration, the caller can submit work and continue without waiting for the consumer to finish. Synchronous communication is useful when the caller needs an immediate result. Asynchronous communication is useful when processing can happen later.

Give an example where asynchronous integration is preferable.

Suppose an order service needs to send a confirmation email after an order is created. The customer does not usually need the email service to finish before the order API responds. The order service can publish an event and let an email consumer process it independently. This reduces coupling between order creation and email delivery.

What are the main failure-handling concerns with asynchronous integration?

Messages may be delivered more than once, processing may fail, or consumers may be temporarily unavailable. Systems commonly address this with retries, idempotent consumers, dead-letter queues, and monitoring. The consumer should be designed so that retrying the same message does not incorrectly repeat the business operation. The exact delivery guarantees depend on the messaging technology and system design.

Is asynchronous processing always non-blocking?

No. Asynchronous integration and non-blocking execution describe different dimensions of a system. A message can be processed asynchronously from the producer's perspective while the consumer itself uses blocking operations. Conversely, a program can use non-blocking APIs while still implementing a request-response interaction. In an interview, I would distinguish communication timing from thread or execution-model behavior.