Back to Catalog
Microservices
Data Management
Saga
Distributed transactions without 2PC β a chain of local transactions with compensating rollbacks.
Intent & Description
Real-world Use Case
PlaceOrder Saga: (1) Order Service creates order β (2) Inventory Service reserves stock β (3) Payment Service charges card. If payment fails β compensating: Inventory releases stock β Order is rejected. All via events or orchestrator.
Source
π TL;DR
Saga = distributed transaction done right. Chain of local transactions + compensating rollbacks. Choose Choreography for simplicity, Orchestration for control.
Advantages
- No distributed transactions or 2PC β scales cleanly
- Each local transaction is ACID within its service
- Orchestration gives full visibility into saga state
- Choreography is fully decentralized β no single point of failure
Disadvantages
- Eventual consistency β system is temporarily inconsistent mid-saga
- Compensating transactions are complex to write and test
- Choreography can become a spaghetti of events hard to trace
- Orchestration introduces a central coordinator to build and maintain
- Debugging failed sagas requires distributed tracing tooling