Core Idea
A saga is a design pattern for managing distributed transactions by decomposing them into a sequence of local transactions, where each local transaction updates a single service’s database and publishes an event or message to trigger the next step.
Definition
A saga manages distributed transactions by decomposing them into a sequence of local transactions. Each step updates a single service’s database and publishes an event or message to trigger the next step. Unlike two-phase commit, sagas maintain consistency through eventual consistency with compensating transactions—business-specific rollback operations that undo previously completed steps when failure occurs. Originally formulated by Garcia-Molina and Salem (1987) for long-lived database transactions, sagas have become essential for microservices where ACID transactions cannot span service boundaries.
Key Characteristics
- Sequence of local transactions: Each step is an ACID transaction within a single service; services commit immediately without holding distributed locks
- Event-driven progression: Local transactions publish domain events (choreography) or receive commands from a central orchestrator (orchestration) to advance the workflow
- Compensating transactions: Business logic that reverses completed steps on failure; compensation is forward-moving, idempotent, and business-specific
- Eventual consistency: The system reaches a consistent state over time; intermediate states may be visible to concurrent operations
- Lack of isolation (ACD, not ACID): Sagas sacrifice the “I” in ACID, exposing risks of lost updates and dirty reads; countermeasures include semantic locks, pessimistic views, and version files
Why It Matters
Sagas solve the fundamental impossibility of distributed ACID transactions across service boundaries. When services own their data, two-phase commit becomes an anti-pattern—it creates tight coupling, reduces availability, and does not scale. Sagas trade isolation for service autonomy and availability, but introduce complexity: developers must design compensating transactions for every step and implement countermeasures against isolation anomalies.
Ford, Richards, Sadalage, and Dehghani identify eight distinct saga variations that trade off communication style (synchronous vs. asynchronous) and consistency model (atomic vs. eventual) against coordination approach (orchestration vs. choreography).
Related Concepts
- Distributed-Transactions - traditional 2PC approach that sagas replace
- Orchestration - centralized coordination approach for sagas
- Choreography - decentralized event-driven coordination for sagas
- ACID - atomicity, consistency, isolation, durability guarantees
- Eventual-Consistency - consistency model sagas provide
- CAP-Theorem - trade-offs between consistency, availability, partition tolerance
- Bounded-Context - service boundaries where sagas coordinate
- Data-Ownership-Patterns - database-per-service enables saga necessity
- Asynchronous-Communication - messaging foundation for saga coordination
- Architecture-Quantum - independently deployable units sagas coordinate across
- Software Architecture - The Hard Parts - Ford, Richards, Sadalage & Dehghani - 2022 - presents eight saga pattern variations
- Epic-Saga-Pattern - Synchronous-Atomic-Orchestrated
- Phone-Tag-Saga-Pattern - Synchronous-Eventual-Choreographed
- Fairy-Tale-Saga-Pattern - Synchronous-Eventual-Orchestrated
- Time-Travel-Saga-Pattern - Synchronous-Eventual-Choreographed
- Fantasy-Fiction-Saga-Pattern - Asynchronous-Atomic-Orchestrated
- Horror-Story-Pattern - Asynchronous-Atomic-Choreographed
- Parallel-Saga-Pattern - Asynchronous-Eventual-Orchestrated
- Anthology-Saga-Pattern - Asynchronous-Eventual-Choreographed
Sources
-
Garcia-Molina, Hector and Kenneth Salem (1987). “Sagas.” ACM SIGMOD Record, Vol. 16, No. 3, pp. 249-259.
-
Ford, Neal; Richards, Mark; Sadalage, Pramod; Dehghani, Zhamak (2022). Software Architecture: The Hard Parts - Modern Trade-Off Analyses for Distributed Architectures. O’Reilly Media. ISBN: 978-1-492-08689-5.
- Chapter 12: Transactional Sagas
-
Richardson, Chris (2025). “Pattern: Saga.” Microservices.io.
-
Daraghmi, Eman; Zhang, Cheng-Pu; Yuan, Shyan-Ming (2022). “Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture.” Applied Sciences, Vol. 12, No. 12, Article 6242. DOI: 10.3390/app12126242.
-
Helland, Pat (2007). “Life Beyond Distributed Transactions: An Apostate’s Opinion.” CIDR 2007 Conference.
Note
This content was drafted with assistance from AI tools for research, organization, and initial content generation. All final content has been reviewed, fact-checked, and edited by the author to ensure accuracy and alignment with the author’s intentions and perspective.