Member-only story

Sagas in Microservices

Naresh Waswani
8 min readJul 26, 2020

--

Everyone is doing Microservices and they just love it. Yes, I am serious, people are loving it. But to be honest, Microservices is not fun. At times, you get into scenarios where there is a need to maintain Data Consistency across participating Microservices. Well, it’s tough to achieve it 100 % with guarantee. But one thing is for sure — once you land in such a situation, you are forced to think — Monolith was much better with Transactions handling in complex scenario 😏.

With Microservices, you can handle transaction spanning across services. It cannot guarantee the Atomicity and Isolation one would expect like ACID in Database. But yes, there are ways to handle Data Consistency to a great extent — Saga Pattern is one such option.

Before jumping into the Sagas, quick words on the communication style of Microservices. Microservices can interact with each other in following patterns —

  1. Request/Response pattern or
  2. Event Based Pattern

Request/Response Based Communication

Request/Response is generally blocking/synchronous in nature. For example, you make a Rest API call (or may be RPC style call like RMI, CORBA, etc.) by sending data in a request payload and until the response is delivered, you wait. And once response is received, you proceed with your next business logic execution.

Request/Response can be Non-Blocking (Asynchronous) as well. This pattern is used when the client can continue executing its business logic…

--

--

Naresh Waswani
Naresh Waswani

Written by Naresh Waswani

#AWS #CloudArchitect #CloudMigration #Microservices #Mobility #IoT

Responses (1)