Video in progress
When is synchronous communication between services the right choice, and when asynchronous?
Synchronous (REST, gRPC) fits when you need the answer right away: "what is the product's price?". Asynchronous (queue, event) fits when you don't have to wait for the result or the work takes long: sending an email, generating a report, processing a video.
📖 Answer
Ask a simple question: "Can the caller move on without the answer?"
If it can't, go synchronous. When placing an order you need to know the product is in stock — otherwise, what do you tell the user?
If it can, go asynchronous. After an order is confirmed, the user doesn't mind if the SMS arrives a few seconds later.
The risk of a synchronous chain: A → B → C → D. If D slows down, everything slows down; if D goes down, A returns an error too. Every call needs a timeout and a path for the failure case.
The risk of asynchronous is different: errors aren't visible right away. A message can get stuck in the queue, or a worker can fail silently. Without a dead letter queue and monitoring, you only find out about the problem when a user complains.
In practice both appear in one flow: checks are synchronous, the following steps go through events.
Sign up to mark studied questions and save your progress.