Engineering Decisions · Senior · Question 5 of 14

An order spans the payment, inventory and shipping services, each with its own database. Any step can fail, and short inconsistency is acceptable. How do you coordinate it?

Show the answer

Correct answer: A saga with compensating actions per step

Explanation

A saga runs local transactions and undoes finished steps on failure, which suits services that own their data and accepts brief inconsistency. Two-phase commit fits a few tightly coupled databases that all support it, but it blocks participants and hurts availability. A shared database fits services that aren't really separate, and it brings back the coupling they were split to avoid.

Further reading

Problem with a question

Engineering Decisions · Senior · question 5

Test yourself

Take the Engineering Decisions · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz