A Real-world Microservices Use Case — Part II
How to communicate among the microservices
In my previous post, I discussed how to define the problem statement and choose the right high-level architecture (e.g., Monolithic vs. Microservices). Now, let’s dive into inter-microservice communication in our bookstore application.
Communication Patterns in Microservices
When breaking an application into multiple microservices, selecting the appropriate communication pattern is crucial. In microservices architecture, two primary communication modes exist:
- Synchronous (Blocking) Communication
- Asynchronous (Non-blocking) Communication
Synchronous-blocking Communication
Synchronous communication is used when the client requires an immediate response, as opposed to waiting for an eventual one. One of the most common protocols for synchronous communication is HTTP, though others are frequently used, including:
- gRPC
- WebSocket
- RMI (Remote Method Invocation)