Synchronous vs asynchronous communication: 3 communication models explained

When one service needs another, does it wait? Does its thread wait? Does it even know who is listening? Three simple questions, three communication models, and how to pick the right one for each part of your system.

Two ways to send a message. On the left, a person holding a phone to their ear next to an hourglass, labelled "Call and wait", which is synchronous. On the right, a person dropping an envelope into a postbox and walking away, while three different readers pick up copies of it, labelled "Send and move on", which is asynchronous and event-driven.
Fig. 1 — Every message between services is either a phone call or a letter. Knowing which one you need is half of system design.

You post a photo on a social app. You have two million followers.

Should the app make you wait until all two million followers have been notified, and only then say “Posted!”? Or should it say “Posted!” straight away, and notify your followers in the background over the next few seconds?

Everyone picks the second one. And without noticing, you’ve just made a communication model decision: you chose asynchronous over synchronous.

In the last two articles we split one application into many services spread over a network. Now those services have to talk to each other. How they talk decides how fast your system feels, how far one failure spreads and how easily it grows. This guide explains the three communication models in plain English, with a simple rule for when to use each.

Why communication models matter

Services in a distributed system don’t share memory. When the Order service needs something from the Payment service, it has to send a message over the network. That raises three questions:

  • Does the caller wait for the answer, or keep going?
  • What happens to the caller’s thread while it waits?
  • What happens if the other service is slow, or down?

The way you answer them shapes four things:

It affects… Because…
Speed Waiting adds time to every request
Reliability If you wait on a broken service, you break too
Coupling The more services know about each other, the harder they are to change
Cost Waiting threads use memory and server capacity while doing nothing

The three communication models at a glance

People often mix these up, so here is the whole map first. There are three separate questions, and each one has two answers:

Three rows, each a question with two answers. Row 1, synchronous vs asynchronous: does the caller wait for the result? Synchronous: yes, like a phone call. Asynchronous: no, like sending an email. Row 2, blocking vs non-blocking: does the thread wait? Blocking: the thread sits idle until the answer arrives. Non-blocking: the thread goes off to do other work and comes back later. Row 3, request/response vs events: does the sender know who is listening? Request/response: yes, it asks one service directly, like asking a waiter. Events: no, it announces something and anyone can react, like a fire alarm.
Three questions, three models. They are independent: you choose an answer to each one.
  1. Synchronous vs asynchronous is about the caller: does it wait for the result?
  2. Blocking vs non-blocking is about the thread: does it sit idle while it waits?
  3. Request/response vs events is about the relationship: does the sender know who receives the message?

Let’s take them one at a time.

Model 1: Synchronous vs asynchronous communication

Synchronous: call and wait

In synchronous communication, the caller sends a request and waits for the response before doing anything else.

Think of a phone call. You dial, you wait for an answer, you talk, you get your reply. If nobody picks up, you’re stuck holding the phone until you give up.

// Java · CheckoutController.java (synchronous)
@PostMapping("/checkout")
public CheckoutResponse checkout(@RequestBody CheckoutRequest request) {
    if (!inventoryClient.isAvailable(request.productId())) {        // wait for inventory
        return CheckoutResponse.outOfStock();
    }
    PaymentResult payment = paymentClient.charge(request.payment()); // wait for the payment gateway
    if (!payment.success()) {
        return CheckoutResponse.paymentFailed();
    }
    return CheckoutResponse.success(payment.transactionId());        // the user gets a clear answer
}

Checkout is synchronous for good reasons: the user needs to know right now whether the payment worked, and the steps must happen in order.

Asynchronous: send and move on

In asynchronous communication, the caller hands off the work and doesn’t wait for it to finish. It gets back a quick “got it” and carries on.

Think of sending an email. You hit send and get on with your day. The reply comes later, whenever it comes.

// Java · VideoController.java (asynchronous)
@PostMapping("/videos")
public ResponseEntity<UploadResponse> upload(@RequestParam("file") MultipartFile file) {
    String videoId = UUID.randomUUID().toString();
    String url = storage.upload(videoId, file);                          // save the raw file

    kafka.send("video-uploads", new VideoUploaded(videoId, url));        // hand off the slow part
    return ResponseEntity.accepted().body(new UploadResponse(videoId, "Processing"));  // 202, right away
}

// Java · a separate service, running in the background
@KafkaListener(topics = "video-uploads")
public void encode(VideoUploaded event) {
    // converting the video can take minutes: nobody is waiting on it
    videos.markReady(event.videoId(), encoder.encode(event.url()));
}

Encoding a video takes minutes. Making the user stare at a spinner for that long would be terrible, so the API replies with 202 Accepted at once, and the work happens in the background.

Two timelines. Synchronous: the client sends a request to the server, then a long grey bar shows the client waiting while the server works, then the response comes back; the client can only continue after that. Asynchronous: the client sends a request, gets back 202 Accepted almost at once and continues with other work; meanwhile the work goes into a queue and a worker processes it; later the result arrives by a notification.
Synchronous: the caller's time is tied to the slowest step. Asynchronous: the caller is free almost at once, but the result arrives later.

Synchronous vs asynchronous: trade-offs

Synchronous Asynchronous
The caller… waits for the result gets “accepted” and moves on
Feedback immediate and clear later, by polling or a notification
If the other side is down the caller fails too work waits in a queue until it’s back
Coupling tight: both must be up at once loose: they don’t need to be up together
Consistency easy: you know the result eventual: the result shows up later
Debugging easy to follow harder: the work hops between services
Extra infrastructure none a queue or message broker

Use synchronous when the user needs the answer to continue: login, payments, checking stock, validating an address.

Use asynchronous when the work is slow or the user doesn’t need the result right now: sending emails and push notifications, encoding video, generating reports, updating analytics.

“Asynchronous doesn’t make the work faster. It makes the waiting someone else’s problem.”

Model 2: Blocking vs non-blocking I/O

The first model was about the caller. This one is about what happens inside the server: what does the thread do while it waits for the network?

Blocking I/O: one thread per waiting request

With blocking I/O, the thread that sends a request sits idle until the answer comes back. It can’t do anything else in the meantime.

// Java · blocking
String user = restClient.get().uri("/users/123").retrieve().body(String.class);
// this thread does nothing until the reply arrives
System.out.println(user);

It’s simple to write and easy to debug: the code reads top to bottom. The catch is that every waiting request holds a thread. With 1,000 requests waiting on a slow service, you need 1,000 threads.

Non-blocking I/O: one thread, many requests

With non-blocking I/O, the thread sends the request, registers “call me when the answer arrives,” and goes off to handle other work. A small number of threads can look after thousands of open requests.

Think of a restaurant. A blocking waiter takes one order, stands at the kitchen door until the food is ready, then serves it. A non-blocking waiter takes your order, passes it to the kitchen, and serves other tables until the kitchen rings the bell.

A great use is calling several services in parallel. With Spring WebFlux’s WebClient:

// Java · ProfileController.java (non-blocking, three calls at once)
@GetMapping("/users/{id}/profile")
public Mono<UserProfile> profile(@PathVariable String id) {
    Mono<User> user = web.get().uri("http://user-service/users/{id}", id)
            .retrieve().bodyToMono(User.class);
    Mono<List<Order>> orders = web.get().uri("http://order-service/orders?userId={id}", id)
            .retrieve().bodyToFlux(Order.class).collectList();
    Mono<Preferences> prefs = web.get().uri("http://preference-service/preferences/{id}", id)
            .retrieve().bodyToMono(Preferences.class);

    return Mono.zip(user, orders, prefs)                              // all three run at the same time
            .map(t -> new UserProfile(t.getT1(), t.getT2(), t.getT3()));
}

If each call takes 100 ms, the blocking version done one after another takes about 300 ms. This one takes about 100 ms, and no thread sits idle while waiting.

Left, blocking: ten threads, each shown as a row with a long grey 'waiting' bar holding one request each; new requests pile up in a queue outside, labelled 'thread pool full'. Right, non-blocking: two threads juggling many requests, sending each one out and picking up answers as they return, with a small event loop icon; the queue outside is empty. A note under each: blocking, about 1 MB of memory reserved per thread; non-blocking, a few threads for thousands of requests.
Blocking ties up one thread per waiting request. Non-blocking lets a few threads juggle thousands.

Blocking vs non-blocking: trade-offs

Blocking I/O Non-blocking I/O
Code style simple, top to bottom callbacks, futures or reactive streams
Debugging easy, clear stack traces harder, stack traces jump around
Threads needed one per waiting request a few for many requests
Under heavy load threads run out, requests queue handles many more open requests
Best for ordinary apps, CPU-heavy work gateways, chat, streaming, lots of slow I/O

Don’t confuse model 1 and model 2

These two are often mixed up, but they are different questions:

  • The profile endpoint above is synchronous for the user (they wait for their profile) but uses non-blocking I/O inside.
  • A Kafka consumer is asynchronous for the user who triggered the work, but it can use plain blocking code to process each message.

Sync vs async is what the caller experiences. Blocking vs non-blocking is how your threads behave. You choose each one separately.

Model 3: Request/response vs events

The last question is about who knows about whom.

Request/response: ask one service directly

In request/response, the caller sends a message to a specific service and expects an answer from it. The caller knows exactly who it is talking to. REST and gRPC calls work this way.

Think of asking a waiter for the menu. You ask a specific person, and you expect that person to bring it.

Events: announce what happened, anyone can react

In the event-driven model, a service publishes an event, a fact about something that happened, such as OrderPlaced. It doesn’t send it to anyone. It doesn’t know or care who is listening. Other services subscribe to the events they care about and react in their own time.

Think of a fire alarm. It doesn’t call each person. It just rings, and everyone who hears it reacts in their own way: people leave, the fire brigade is called, the lifts go to the ground floor.

// Java · OrderService.java (publisher: knows nothing about who listens)
public Order placeOrder(OrderRequest request) {
    Order order = orders.save(new Order(request));
    kafka.send("order-events", new OrderPlaced(order.id(), order.userId(), order.items()));
    return order;
}

// Java · three separate services, each reacting on its own
@KafkaListener(topics = "order-events", groupId = "email")
public void sendConfirmation(OrderPlaced e) { emails.sendOrderConfirmation(e); }

@KafkaListener(topics = "order-events", groupId = "inventory")
public void reduceStock(OrderPlaced e) { inventory.decrement(e.items()); }

@KafkaListener(topics = "order-events", groupId = "analytics")
public void record(OrderPlaced e) { analytics.recordOrder(e); }

Notice what the Order service doesn’t do: it never calls the email, inventory or analytics services. Tomorrow you can add a loyalty-points service that listens to the same event without changing a single line of the Order service. And if the email service is down, orders still go through; the emails go out when it’s back.

Left, request/response: the Order service draws three direct arrows to the Email, Inventory and Analytics services, and must know about each of them and wait for each answer. Right, events: the Order service drops one OrderPlaced event onto an event bus, and the Email, Inventory, Analytics and a new dashed Loyalty points service each pick it up on their own. A label notes: add a new listener without touching the Order service.
Request/response: the sender knows everyone. Events: the sender knows no one, so new listeners plug in freely.

Request/response vs events: trade-offs

Request/response Events
The sender knows the receiver? yes no
Answer back? yes, right away no direct answer
Adding a new consumer change the caller just subscribe
One receiver is down the caller sees an error the others carry on
Following the flow easy: read the code harder: you need tracing and good event names
Best for queries and commands that need an answer telling others “this happened”

Use request/response when you need an answer: “Is this item in stock?”, “Charge this card.”

Use events when you’re announcing a fact that several parts of the system might care about: “An order was placed.”, “A user signed up.”, “A video is ready.”

Putting it together: a food delivery order

Real systems mix all of these. The trick is to choose per step, not per system. Here’s how a food delivery app might handle one order:

A food delivery order split into two lanes. The synchronous lane, while the customer waits on the checkout screen: validate the address, check the restaurant is open, charge the card, save the order, then show 'Order placed!'. The asynchronous lane, after the screen has already said 'Order placed!': an OrderPlaced event goes onto the event bus and fans out to notify the restaurant, assign a rider, send the confirmation email and push notification, and update analytics.
Wait only for what the user needs to see. Everything else happens after the screen says 'Order placed!'.
// Java · OrderController.java (mixing both)
@PostMapping("/orders")
public ResponseEntity<OrderResponse> placeOrder(@RequestBody OrderRequest request) {
    PaymentResult payment = payments.charge(request.payment());        // SYNC: the user must know
    if (!payment.success()) {
        return ResponseEntity.badRequest().body(OrderResponse.paymentFailed());
    }
    Order order = orders.save(new Order(request, payment));

    events.publish(new OrderPlaced(order));                              // ASYNC: restaurant, rider, email...
    return ResponseEntity.ok(OrderResponse.placed(order.id()));          // reply now
}

The customer waits a second or two for the payment, which is fine because they need that answer. They don’t wait for the email, the analytics or the rider search.

What breaks, and how to fix it

Each model has its own way of failing. These four come up again and again:

What breaks What you see The fix
A sync call with no timeout A slow service freezes every caller, then theirs Always set a connect and request timeout, plus a fallback
Too many blocking threads Thread pool full, requests queue, then the server falls over Bounded pools and queues, non-blocking I/O, or virtual threads
Callback hell in async code Deeply nested callbacks that nobody can read or debug CompletableFuture chains or reactive streams, with errors handled in one place
Lost events The database saved the order, but the broker was down, so the event never went out The transactional outbox: save the event in the same database transaction, and send it from there

The first fix is the one that matters most. With Java’s built-in HTTP client:

// Java · never wait forever
HttpClient client = HttpClient.newBuilder()
        .connectTimeout(Duration.ofSeconds(2))       // how long to wait to connect
        .build();

HttpRequest request = HttpRequest.newBuilder(URI.create("http://inventory/stock/42"))
        .timeout(Duration.ofSeconds(3))              // how long to wait for the answer
        .build();

The last one, the transactional outbox, deserves a closer look. The problem: you save the order, then try to publish the event, and the broker is down. Now the order exists, but no email, no stock update, nothing. The fix: in the same database transaction as the order, write the event to an outbox table. A small background job reads that table and publishes each event, retrying until it succeeds. The order and its event either both exist or neither does.

Puzzle 1: “We made it async and it got slower”

Asynchronous doesn’t make the work faster. It makes the reply faster. The work still takes 5 seconds, plus a little extra for the queue. And now the user has to find out when it’s done: refresh the page, poll the API, or wait for a notification that arrives after 6 seconds.

If the user needs the result to continue, async just moves the waiting somewhere more confusing. Async is better when the user doesn’t need the result right now, not as a speed trick.

Puzzle 2: the synchronous chain

All four must work at the same moment, so you multiply: 0.999 × 0.999 × 0.999 × 0.999 ≈ 0.996. That’s 99.6%: about 2.9 hours of failures a month, instead of 43 minutes for one service.

Synchronous chains multiply failure. Keep them short. Make steps asynchronous where the user doesn’t need the answer, and use timeouts and circuit breakers on the calls that stay synchronous.

A quick way to choose

For each interaction, ask three questions:

  1. Does the user need this answer to continue? Yes: synchronous. No: asynchronous.
  2. Is this server mostly waiting on other services, under heavy load? Yes: consider non-blocking I/O or virtual threads. No: plain blocking code is fine.
  3. Am I asking for something, or announcing that something happened? Asking: request/response. Announcing: events.

Key takeaways

  1. There are three communication models, each answering a different question: does the caller wait, does the thread wait, does the sender know the receiver?
  2. Synchronous is simple and gives instant answers, but couples services and spreads failures. Use it when the user needs the result.
  3. Asynchronous frees the caller and isolates failures, but adds queues, delay and harder debugging. Use it for slow or background work.
  4. Non-blocking I/O (or Java’s virtual threads) lets a few threads handle thousands of waiting requests.
  5. Events let services react without knowing each other, so you can add new features without touching the publisher.
  6. Mix them. Choose per step, not per system: wait only for what the user must see.

Next in this thread: the protocols that carry these messages, REST, gRPC, GraphQL and WebSockets, and how to pick between them.

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.