Skip to content

Saga Pattern

Long-running business transactions across multiple services can be modeled as a sequence of local transactions, each with a compensating action that semantically undoes its effect, avoiding distributed locks while maintaining business consistency.

Tension Addressed

Autonomy vs. Coordination (enables cross-service transactions without blocking coordination)

Recognizable As

Choreography (events trigger next steps) vs orchestration (central coordinator); compensation handlers; "pending" states in workflows; rollback procedures that aren't just database rollbacks

Canonical Sources

Garcia-Molina & Salem, "Sagas" (1987); Helland, "Life Beyond Distributed Transactions" (2007); Richardson, "Microservices Patterns" (2018)

Transfers To

Workflow Systems (long-running processes), Payment Processing (multi-step transactions), Order Fulfillment (cross-system coordination), Travel Booking (hotel + flight + car)

Sagas emerged from the recognition that distributed transactions (2PC) don't scale: they require all participants to be available simultaneously and hold locks for the duration. Sagas accept that intermediate states are visible and design compensating actions to handle failures at any step.

Sub-concepts: - Choreography vs. Orchestration: Services react to events vs. central coordinator directs flow - Semantic Compensation: Undo actions that maintain business meaning even if they can't restore exact prior state