Practice the vocabulary of coordinating a multi-step transaction across independent services.
0 / 5 completed
1 / 5
At standup, a dev mentions coordinating a multi-step transaction across several independent services using a sequence of local transactions, each with a defined compensating action if a later step fails. What is this pattern called?
The saga pattern coordinates a multi-step transaction across several independent services using a sequence of local transactions, each paired with a predefined compensating action that can undo its effect if a later step in the sequence fails. This avoids needing a traditional distributed transaction that locks every involved service simultaneously, which doesn't scale well across independently owned microservices. It trades the strict atomicity of a classic distributed transaction for eventual consistency achieved through this compensating-action sequence.
2 / 5
During a design review, the team wants a failed step partway through a saga to trigger the previously completed steps' compensating actions in reverse order, undoing their effects. Which capability supports this?
Orchestrated compensation on saga failure triggers the compensating action for each previously completed step, typically in reverse order, undoing their individual effects when a later step in the sequence fails. Leaving every completed step's effect permanently in place despite a later failure leaves the overall system in an inconsistent state that doesn't reflect the transaction's actual, ultimately failed outcome. This compensation logic is what gives a saga its eventual all-or-nothing behavior despite being built from several separate local transactions.
3 / 5
In a code review, a dev notices a central orchestrator service explicitly directs each step of the saga and calls the appropriate compensating action if needed, rather than each service reacting independently to events with no central coordination. What does this represent?
Orchestration-based saga coordination uses a central orchestrator service to explicitly direct each step and invoke the appropriate compensating action if needed, giving the team one clear place to see and reason about the whole sequence. This differs from choreography-based coordination, where each service reacts independently to an event with no single central coordinator, which can be harder to trace but avoids a single orchestrator becoming a bottleneck. Both are valid saga coordination styles with different tradeoffs around visibility versus decentralization.
4 / 5
An incident report shows a saga's compensating action for one step failed partway through, leaving the overall transaction in a partially undone, inconsistent state that no one noticed for days. What practice would prevent this?
Monitoring for a failed compensating action and alerting so it can be resolved, whether manually or through an automated retry, prevents a partially undone saga from silently sitting in an inconsistent state undetected. Assuming every compensating action always succeeds ignores that a compensating action is itself just another operation that can fail. This monitoring of the compensation path itself, not just the forward path, is an often-overlooked but essential part of a robust saga implementation.
5 / 5
During a PR review, a teammate asks why the team uses the saga pattern instead of a traditional distributed transaction that locks every involved service until the whole operation commits. What is the reasoning?
A traditional distributed transaction locking every involved service simultaneously until the whole operation commits creates tight coupling and contention that doesn't scale well across independently owned, independently deployed microservices. A saga instead achieves eventual consistency through a sequence of local transactions, each with its own compensating action if something fails later. The tradeoff is that a saga only provides eventual, not immediate, consistency, and requires the added complexity of designing a correct compensating action for every step.