Curriculum · Module 08, Distributed Transactions
Sagas and compensation
Split one big transaction into local steps and undo with new steps when one fails. Orchestration and choreography coordinate them, and readers can see the middle.
What each topic covers
- A locked transaction across services is slow and fragile. A saga trades the lock for a way to take a step back.
- Each step has a compensating action. When a step fails, the saga runs the undos of the finished steps, last first.
- Run sagas with failing steps and undos, switch coordination style, and turn a semantic lock on and off.
- Sagas give up isolation. Readers can see steps that are later undone, and a long saga fails more often than a short one.
- Orchestration puts the flow in one place and costs messages. Choreography has no owner and is hard to follow.
- A compensation can fail too. Retry it safely, then park the saga for a person.
- Three quick checks on what a compensation is, what a saga does not give you and how the two styles differ, with the sources behind the lesson.
Topics
Practise this lesson
8 interview questions on sagas, with worked answers and sources.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms