What is Saga Pattern?
The saga pattern manages distributed transactions across multiple microservices using a sequence of local transactions, each with a compensating action for rollback.
The saga pattern manages distributed transactions across multiple microservices using a sequence of local transactions, each with a compensating action for rollback. Unlike traditional ACID transactions (which require a central coordinator), sagas use eventual consistency and compensation.
Saga types: Choreography (each service emits events, other services react — no central coordinator, less coupling, harder to track), and Orchestration (a central saga orchestrator directs the flow — easier to understand, single point of coordination).
Example: Order saga — 1) Create order (compensating: cancel order), 2) Reserve inventory (comp: release inventory), 3) Charge payment (comp: refund payment), 4) Ship order (comp: cancel shipment). If step 3 fails, compensating actions for steps 1-2 execute in reverse order.
Why It Matters
Distributed transactions (2PC) don't scale and tightly couple services. The saga pattern provides a scalable alternative for maintaining data consistency across microservices without distributed locks.
Frequently Asked Questions
What is the saga pattern?
Managing distributed transactions via a sequence of local transactions, each with a compensating (rollback) action. Provides consistency across microservices without distributed locks.
Choreography vs orchestration sagas?
Choreography: services react to events (no coordinator, more decoupled, harder to debug). Orchestration: central coordinator directs flow (easier to understand, single point of coordination). Most teams start with orchestration.
Related Terms
Need Expert Help?
Richard Ewing is a Product Economist and AI Capital Auditor. He helps companies translate technical complexity into financial clarity.
Book Advisory Call →