Video in progress

How do you decide whether service-to-service communication for a new feature should be synchronous or asynchronous?

The main question is whether the caller needs the result now, inside this request. If so, synchronous, but with a timeout and a fallback. If not, an event or message: the coupling in time goes away, but you take on eventual consistency, observability and dealing with duplicates.

📖 Answer

I ask a few questions in a row.

Is the user waiting for the result? "Is the promo code valid?" Yes, synchronous. "Calculating a bonus after the order": no, the user will see it later.

What happens if the downstream is gone? With synchronous calls your availability is the product of all the services in the chain: 5 services at 99.9% each give about 99.5%, which is around 3.5 extra hours of failure per month. With asynchronous calls, even if the downstream is down for an hour, messages wait in the queue.

Who needs to know whom? In a synchronous call, order knows notification. With an event, order only says "an order was created", and who listens is not its business. Adding a new consumer doesn't require changing order.

If the result is an error, how do we tell the user? In asynchronous flows the error comes later, and showing it takes UI and notifications. People often forget this.

In practice most processes are a mix:

Step Communication
Checking the cart, calculating the price synchronous
Creating the order synchronous, returns 202
Warehouse, payment, delivery asynchronous saga
Email, analytics, bonus asynchronous events

When you choose asynchronous, the team has to be ready: outbox, idempotent consumer, DLT, consumer lag monitoring, tracing that carries through Kafka. Without these, an asynchronous system gives you more trouble than a synchronous one, because errors now disappear silently.

Async request/reply (putting the request on a queue and waiting for the answer on another queue) often combines the bad sides of both worlds. I use it only when there is a clear reason.