Saga Pattern: Distributed Transactions via Choreography and Orchestration
Fast recall
Quick revision
Core answer
Whether you know how to maintain data consistency across microservices without distributed ACID transactions (which don't scale)
Confusing Saga with 2-phase commit, or not knowing how compensating transactions differ from rollbacks (they're new forward transactions, not undos)
Explain the difference between choreography and orchestration, when each breaks down, and mention Axon Framework or Spring State Machine as orchestration implementations
Interview-ready guide
Interview answer
The Saga pattern is how microservices achieve consistency across databases without distributed ACID transactions.
- Two-phase commit locks rows across all participants until every database votes — at thousands of operations per second, that becomes a global mutex that kills throughput.
- Sagas take a different approach: each service executes a local transaction and publishes an event.
- If a later step fails, compensating transactions undo the effect.
The key insight about compensation:
- Compensation is not a database rollback — when payment succeeded but inventory is out of stock, you issue a refund, which is a new forward transaction that creates a credit record, notifies the payment gateway, and updates the ledger
- Compensating transactions must be idempotent because at-least-once delivery means a compensation command can arrive twice — "release reserved inventory" must be safe to call multiple times
- Every step must have a defined compensation that can be executed independently of the system's current state
Choreography vs orchestration:
- Choreography has no central coordinator — services react to each other's events; clean for 2–3 step flows, but once you have six services reacting to each other's success and failure events, the interaction graph becomes unmanageable and tracing what happened requires following events across dozens of topics
- Orchestration puts the flow in a dedicated state machine — it sends commands, tracks which steps completed, and drives compensation when something fails; you can query it at any moment and know exactly where the saga stands; for Java, Axon Framework provides this with persistent state and retry
Visibility and monitoring:
- Monitor saga duration and alert when one stays in an intermediate state beyond your SLA — the most common cause is a consumer crash with a message stuck in a dead-letter queue
I recommend choreography for simple linear flows with 2–3 services, and orchestration for anything with conditional logic, many participants, or business-critical flows where operational visibility matters.
Saga Pattern: Distributed Transactions via Choreography and Orchestration
Direct Answer
The saga pattern manages distributed transactions by breaking them into a sequence of local transactions, each publishing an event that triggers the next step. On failure, compensating transactions undo completed steps. choreography uses direct event reactions with no central coordinator; orchestration uses a central saga orchestrator that explicitly controls the flow.
Common Mistakes & Pitfalls
Confusing Saga with 2-phase commit, or not knowing how compensating transactions differ from rollbacks (they're new forward transactions, not undos)
Check your understanding
Answer these without looking back at the article.
- How do you handle a compensating transaction that itself fails?
- What is the difference between a Saga and a Process Manager?
- How does the Axon Framework implement the saga pattern in Java?
Related interview prep categories
2Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.