2019-08-07

2019-08-07 Wednesday - Microservices Saga Pattern


Photo by Eduardo Flores on Unsplash
https://unsplash.com/photos/qJ4FCI0sx98


In Madhuka Udantha's recent DZone article, Design Patterns for Microservices,  I noted he placed the Saga Pattern in a Database Pattern collection.

I wonder if this is perhaps because he is defining it in a strict alignment with the original 1987 paper by Hector Garcaa-Molrna Kenneth Salem?

It seems misplaced though there, to me...given the utility of Saga Pattern for orchestration, choreography, or database coordination...

Typically, I think of the Saga Pattern in terms of a type of Integration Pattern...of which orchestration or choreography could be just subtypes...if not outright peer level collections to the Database level collection that he defines...

Since the Saga Pattern may be used to manage the loose orchestration with other services (either internal, or external) - but may not be dealing directly with a database at all - the placement in Database collection seems out of place...?


Background Reading:

See Arnon Rotem-Gal-Oz's 2012-2013 blog postings:


Chris Richardson's article, from earlier this year - which aligns more closely with  Madhuka's name grouping...

Distributed Sagas for Microservices, by  (2018)

Saga: How to implement complex business transactions without two phase commit, by Bernd Rücker (2018)

You may also find these patterns in Thomas Erl's site (re: Arcitura Education Inc) of interest:

1 comment:

Madhuka said...

Problem:
In Microservices, each service has its own database and a business transaction spans multiple services,

how do we ensure data consistency across services?

For example, for a Banking application where customers have a credit card and it has a credit limit. The application must ensure that any transaction will not exceed the customer’s credit limit. Since Transaction, credit card, and Customers are in different databases, the application cannot simply use a local ACID transaction.

Solution:

A Saga represents a high-level business process that consists of several subrequests, which each update data within a single service. Each request has a compensating request that is executed when the request fails. It can be implemented in two ways Choreography and Orchestration.

Answer:

Problem domain was in the data layer (database). Saga Pattern can lay in Database Patterns. It is not a hard rule and it may in Integration pattern.

Copyright

© 2001-2021 International Technology Ventures, Inc., All Rights Reserved.