Member-only story
Microservices Communication — part 2— Sync vs Async vs Hybrid?

Hello Everyone. In the previous article, we saw that there are just 3 ways of communication between the services i.e synchronous, asynchronous, and hybrid. In the first part of this article, we saw in detail the Synchronous Communication between microservices. In this article, we are going to explore Asynchronous communication between microservices. We will see about three types of patterns used in async i.e one-to-one, one-to-many, and event-driven. Then we will see hybrid communication that uses the combination of sync and async communication Toward the end of the article, we are going to see the use cases, benefits, and drawbacks of these different communication mechanisms. Let’s get started.
1. Synchronous Communication
Please check out Microservices Communication part 1 before you read this article.
2. Asynchronous Communication
In Asynchronous communication, a microservice sends a request to another microservice but it doesn’t wait for a response. Hence microservice A will not have blocked a thread while waiting for a response from service B. It is a one-way communication and hence non-blocking in nature. This will save a lot of resources and helps to perform efficient parallel processing.

We can easily handle multiple consumers at a time because it is loosely coupled. Service A does not know the whereabouts of Service B and its instances. It just pushes to the specific Queue and continues its job while Service B will have consumer polling for messages in the Queue. As soon as a message arrives in the Queue, it will be picked up by Service B and processed. Handling failures in this pattern is also easy as we have ways to reprocess the messages.