Retail Microservices: Service to Service Communication

Saurav Samantray
2 min readMar 23, 2020

--

Microservices demand that our services need to be granular and as loosely coupled as possible. With each functionality being deployed as a separate service, it’s imperative to have a way of communication between them.

Synchronous: Making a request to a service and waiting for a response. HTTP has been the industry standard for such communication.

Example — Assume you have an eCommerce application. User wants to add an item to the cart. The add item service will depend on catalog, pricing and Inventory service. Add item service can make a Synchronous HTTP call to each of these service, collect response, perform the add operation and then finally return the success or failure of the overall add operation.

Adding an item to Cart

Asynchronous: A service sends a message or communication to another message and doesn’t wait for the response. This type of communication can be established using a messaging broker. This can be implemented in a one-to-one (Queue) or one-to-many (Topic) form. Apache Kafka and RabbitMQ are couple of popular message brokers.

Example — Assume a customer registers at your eCommerce website. It is crucial to perform the register operation synchronously and provide an update to customer if the registration was successful or not. However, the registration confirmation email can be sent asynchronously.

User Registration

--

--

No responses yet