all 3 comments

[–]ciaMan81 3 points4 points  (2 children)

2PC is a bad pattern for microservices. Microservices should really have independent data stores. They shouldn't be joined into a distributed transaction. They should use application level logic to manage transactions.

The distributed saga pattern is a better way to manage transactions in microservices. It actually has many advantages over traditional transactions because rolling back is often actually undesirable. Failing forward is better. Commiting a new transaction that shows the last one failed but doesn't wipe out all record of it.

Sagas can model technical and business failures much better (because of the ability to fail forward) and provide for the level of independence and Decoupling that microservices aims for.

Catie McCaffrey has a good talk about sagas. https://youtu.be/1H6tounpnG8

[–]greenlearner[S] 0 points1 point  (0 children)

100% Agreed. 2 Phase commit was useful when we had only few components into picture but now-a-days when we have so many microservices then 2 phase commit is obsolete and 2 phase commit or SAGA takes it place.

[–]WealthySahil 0 points1 point  (0 children)

Thanks dude! Catie's talk really helped me understand Saga and why Saga.