Saga Pattern in System Design: Orchestration vs Choreography
-
Last Updated: November 16, 2026
-
By: javahandson
-
Series

Saga pattern explained for system design — orchestration vs choreography, compensating transactions, the pivot step, and the isolation gap, in simple terms.
Picture a simple online order. You click buy, money leaves your account, stock goes down, and a courier picks it up. On a single database, this is easy, because one transaction wraps all of it. If one step fails, the whole thing rolls back and nobody notices. But move that same order across many services, and this safety net quietly disappears. That gap is exactly why the saga pattern exists.
Now split that order across many small services. Payment lives in one service, inventory in another, and shipping somewhere else. Each one owns its own database. Suddenly there is no single transaction to lean on. Therefore, we need a new way to keep everything consistent when work is spread out.
In this article, we will unpack the saga pattern from a pure system design angle. We will look at how it works, the two ways to coordinate it, and how compensating transactions clean up a half-finished job. The ideas here stay language-neutral, so they apply whether you build in Java, Go, or anything else.
By the end, you will know when to reach for orchestration, when choreography fits better, and what traps to avoid. These questions come up often in senior system design interviews too. So the payoff is both practical and career-focused.
Before the saga, let us see the problem it solves. The trouble starts the moment one business action touches more than one database.
A traditional database gives you ACID transactions. The four letters stand for atomicity, consistency, isolation, and durability. In plain words, a group of changes either all succeed or all fail together.
This guarantee is a gift. You rarely have to think about half-done work. The database does the hard part for you. If the payment update fails, the order insert rolls back on its own.
Microservices break that comfort. Each service keeps its own data store, which is good for independence. However, it means one business flow now spans several databases that do not share a transaction.
You might think a distributed transaction could stitch them back together. Protocols like two-phase commit try to do exactly that. Still, they come with heavy costs, since every service must stay locked and available until the whole thing finishes. That hurts both speed and uptime.
So we need another way. We need a method that keeps data consistent across services without locking everything at once. That is the job of the saga pattern.
The saga pattern manages a transaction that spans many services by breaking it into a sequence of small local transactions. Each service does its own bit of work and commits to its own database. Then it signals the next step to begin.
The idea is old. Hector Garcia-Molina and Kenneth Salem first described sagas in a research paper back in 1987. The concept sat quietly for years. Later, when microservices took off in the 2010s, the saga suddenly became relevant again.
You will spot sagas all over modern systems. A travel booking that reserves a flight, a hotel, and a car is a classic case. An e-commerce checkout, a banking transfer across accounts, and a ride-booking flow all follow the same shape. In each one, several services must agree, yet none of them shares a single database.
Think of a saga as a relay race. Each runner finishes their lap and passes the baton. No single runner covers the whole track. In the same way, each service finishes its local transaction and hands off to the next.
Moreover, every local transaction follows these simple rules:
Here is the catch. Once a local transaction commits, it is done for good. You cannot simply roll it back like a single database would. So what happens when a later step fails?
This is where compensating transactions come in. A compensating transaction is a new action that undoes the effect of an earlier step. It does not erase history. Instead, it applies an opposite action that cancels out the earlier change.
A quick example makes this clear. If one step charged money, its compensating action refunds that money. If a step reserved stock, the compensating action releases that stock. The system walks backward, step by step, until the mess is cleaned up.
Let us ground this with a familiar flow. Imagine an e-commerce order that moves through three services in order:
Suppose the first two steps succeed but inventory fails because the item just went out of stock. The saga must now undo the earlier work. It refunds the payment and cancels the order. The customer ends up where they started, with no money lost and no ghost order left behind.
Saga flow — happy path and failure path
HAPPY PATH 1. Create Order -> committed 2. Charge Payment -> committed 3. Reserve Inventory -> committed => Order confirmed FAILURE PATH (inventory out of stock) 1. Create Order -> committed 2. Charge Payment -> committed 3. Reserve Inventory -> FAILS -- run compensations in reverse -- C2. Refund Payment -> committed C1. Cancel Order -> committed => System back to a consistent state
A saga can react to trouble in two directions. Both aim for a clean, consistent end state. The direction simply depends on the step that failed.
Backward recovery is the undo path. When a step cannot proceed, the saga triggers compensating transactions for all completed steps. It rolls the business flow back to a safe starting point. Our refund-and-cancel example above used backward recovery.
Forward recovery is the keep-going path. Some steps must finish no matter what, like sending a shipment after payment clears. Rather than undo, the saga retries the failing step until it succeeds. We will see why some steps demand this treatment when we discuss transaction types later.
A saga is a sequence of steps, but someone has to decide the order. Who tells the next service to run? Who starts the compensations when things go wrong? There are two well-known answers, and the choice shapes your whole design.
The first is choreography, where services talk to each other through events with no central boss. The second is orchestration, where a single coordinator runs the show. Let us look at each one closely, with the same order example running through both.

In a choreography-based saga, there is no central controller. Each service simply listens for events and reacts. When a service finishes its local transaction, it publishes an event. Other services subscribe to that event and do their part next.
Think of it like a group of dancers who all know the routine. Nobody shouts instructions. Each dancer watches the others and moves at the right moment. The flow emerges from everyone following the same shared cues.
In software terms, the services are loosely linked through a message broker. One event leads to another, and the chain moves forward on its own. For compensation, the same idea runs in reverse, with failure events triggering undo actions.
Here is how our order flows through a choreographed saga, step by step:
Choreography — event chain (no central coordinator)
Order Service --(OrderCreated)--> Payment Service Payment Service --(PaymentCompleted)--> Inventory Service Inventory Service --(InventoryReserved)-> Order confirmed ON FAILURE: Inventory Service --(InventoryFailed)--> Payment Service (refund) Payment Service --(PaymentReversed)--> Order Service (cancel)
| 💡 Interview Insight In interviews, a strong line is this: choreography spreads the workflow across services, so nobody owns the full picture. That makes it great for simple flows but painful to trace once the saga grows to many steps. |
An orchestration-based saga takes the opposite stance. Here, one central service called the orchestrator runs the whole flow. It tells each participant what to do and waits for the reply. Then it decides the next move.
Go back to the dance floor, but add a director this time. The director calls each move and watches every dancer. If one dancer stumbles, the director decides whether to pause, retry, or reset the routine. The dancers only follow instructions.
The orchestrator holds the state of the saga. It knows which steps are done and which remain. Most importantly, it owns the recovery logic. When a step fails, the orchestrator fires the compensating commands in the right order.
The same order now runs under an orchestrator. Notice how all the decisions sit in one place:
Orchestration — central coordinator issues commands
+----------------------+
| Saga Orchestrator | (holds saga state)
+----------------------+
| 1. Create Order
| 2. Charge Payment
| 3. Reserve Inventory
v
Order --> Payment --> Inventory
If step 3 fails, orchestrator runs:
Refund Payment -> Cancel Order| 💡 Interview Insight A smart interview point: keep the orchestrator focused on sequencing only. Push the real business rules into the services. An orchestrator stuffed with business logic becomes a new monolith in disguise. |
Both styles reach the same goal. They just split the responsibility differently. The table below lines up the trade-offs so you can pick with confidence.
| Aspect | Choreography | Orchestration |
|---|---|---|
| Control | Spread across services | Central coordinator |
| Coupling | Loose, event-driven | Tighter, command-driven |
| Single point of failure | None by design | Orchestrator must be resilient |
| Visibility | Hard to trace | Clear, one place to look |
| Best for | Few, simple steps | Many or complex steps |
| Debugging | Harder as it grows | Easier to reason about |
As a rough rule, reach for choreography when the flow is short and simple. Switch to orchestration when the flow grows long, branches often, or needs careful recovery. Many real systems even mix both, using small choreographed groups inside a larger orchestrated flow.
Compensating transactions are the heart of saga reliability. Get them wrong, and your undo logic becomes the new source of bugs. So they deserve careful design.
Messages get lost, retried, and sometimes delivered twice. Because of this, a compensating action might run more than once. An idempotent action produces the same result no matter how many times it runs. For example, a refund should never pay the customer twice, even if the refund command arrives again.
A compensating transaction rarely rewinds the world to its exact starting state. Instead, it offsets the effect of the earlier step. A sent email cannot be unsent, for instance. So the compensation might be a follow-up email that says please ignore the previous message.
Also, the undo order need not match the exact reverse of every step. Some compensations can even run in parallel when the steps do not depend on each other. The goal is a consistent end state, not a frame-by-frame rewind.
Here is a hard truth. The compensating transaction itself can fail. A refund service might be down at the very moment you need it. When that happens, the system can get stuck between states.
To handle this, record progress carefully. The saga should be able to resume a compensation from where it stopped. Idempotent, retryable compensations save you here, because you can safely run them again until they finally succeed.
Not every step in a saga behaves the same way. A well-designed saga sorts its steps into three groups. Knowing these groups helps you place risky actions in the right spot.
The pivot is the key idea here. It marks the line between undoable and committed. Before the pivot, you can still roll everything back. After the pivot, you must push forward until the saga finishes.
This is why step order matters so much. An irreversible action, like a payout or a shipment, should sit at or after the pivot. Put it too early, and you lose the ability to cleanly undo. Place it wisely, and the saga stays safe.
| 💡 Interview Insight Interviewers love this: a payout cannot be compensated cleanly, so it should be the pivot or a retriable step. Never place an irreversible action among the early compensatable steps, or your rollback story breaks. |
Here is a subtle point that trips up many people. A saga gives up one of the ACID guarantees, and that is isolation. Chris Richardson famously describes sagas as ACD, meaning atomicity, consistency, and durability, but not isolation.
Why does isolation go missing? Because each step commits right away. While a saga is still running, its half-done changes are already visible to others. Another saga can read or even change that same data mid-flight. That opens the door to anomalies.
You cannot add true isolation back easily. However, you can reduce the damage with a few known tricks. These are called countermeasures, and they are design techniques rather than database features. In practice, you often combine two or three of them in the same saga.
The semantic lock is the most popular of these. Those PENDING or APPROVAL_PENDING states you often see in real systems are exactly this trick at work. In effect, they recreate a soft version of the isolation that ACID gave you for free.
A saga leans heavily on messages and events. So one quiet problem deserves a mention. What if a service commits its local change but then crashes before publishing the event? In that case, the next step never fires, and the saga stalls.
Luckily, the outbox pattern fixes this gap. A service writes the event into an outbox table inside the same local transaction as the business change. Because both land in one commit, they cannot drift apart. Later, a separate process reads the outbox and publishes the events reliably.
You do not need the full details here. Just remember the pairing. Sagas and the outbox pattern usually travel together, because reliable event delivery is what keeps the whole chain honest.
People often compare the saga pattern with two-phase commit, or 2PC. Both try to keep data consistent across services. Yet they take very different paths to get there.
Two-phase commit is a blocking protocol. It locks all participants and makes them wait until every service agrees to commit. This gives strong consistency, but it hurts availability. If one service is slow or down, the whole transaction stalls.
The saga pattern trades that strict consistency for availability. It never holds global locks. Instead, it accepts eventual consistency and cleans up through compensations. As a result, sagas scale better and stay available even when a service wobbles.
| Aspect | Two-Phase Commit | Saga Pattern |
|---|---|---|
| Consistency | Strong, immediate | Eventual |
| Locking | Global locks held | No global locks |
| Availability | Lower, blocking | Higher, non-blocking |
| Failure handling | Rollback by protocol | Compensating transactions |
| Best fit | Few services, strict needs | Many services, high scale |
The saga pattern is powerful, but it is not a default choice for everything. Use it where it truly fits, and skip it where simpler tools work.
In short, the saga shines in distributed, loosely coupled systems. It struggles when the business rules demand tight, lock-step consistency. Match the tool to the need, and you will avoid a lot of pain.
A few mistakes show up again and again with sagas. Spotting them early saves hours of debugging later.
System design interviews love the saga pattern, because it tests real distributed thinking. When the topic comes up, lead with the core trade-off. Say clearly that a saga swaps strict isolation for availability and loose coupling.
Next, show you know both coordination styles. Explain that choreography suits simple flows while orchestration suits complex ones. Then name the pivot transaction and compensating actions, since these prove you understand failure handling, not just the happy path.
Finally, mention countermeasures like the semantic lock. That single term signals deep understanding of the isolation gap. Interviewers remember candidates who talk about the messy parts, not only the clean diagram.
A: The saga pattern manages a transaction that spans many services by breaking it into a sequence of small local transactions. Each service commits its own step, then triggers the next. If a step fails, compensating transactions undo the earlier steps so the system reaches a consistent state.
A: In orchestration, one central coordinator tells each service what to do and owns the recovery logic. In choreography, there is no coordinator — services publish and react to events on their own. Choreography suits small, simple flows; orchestration suits larger or more complex ones.
A: A compensating transaction is a new action that undoes the effect of an earlier committed step. It does not erase history; it applies an opposite action. For example, if one step charged a card, its compensating action issues a refund. Compensations should be idempotent so they stay safe if retried.
A: A saga keeps atomicity, consistency, and durability but gives up isolation. Each step commits immediately, so half-done changes are visible to other sagas while one is still running. This can cause dirty reads and lost updates, which you reduce with countermeasures like semantic locks.
A: The pivot is the go or no-go point of a saga. Before it, every step can be undone with a compensating action. Once the pivot commits, there is no turning back, so the saga must run forward to completion. Irreversible actions, like a payout, belong at or after the pivot.
A: Two-phase commit gives strong, immediate consistency but holds global locks and blocks on failures, which lowers availability. The saga pattern avoids global locks and accepts eventual consistency, so it scales better and stays available. Prefer sagas for many loosely coupled services at high scale.
The saga pattern solves a problem that every microservices team eventually meets. When one business action spans many services, a single ACID transaction is no longer possible. The saga answers this by chaining local transactions and cleaning up failures with compensating transactions.
Two styles coordinate the flow. Choreography keeps it decentralized through events, which fits small and simple sagas. Orchestration adds a central coordinator, which fits larger and more complex flows. Neither is strictly better, so choose based on your workflow.
Remember the trade-off at the center of it all. A saga gives up isolation and accepts eventual consistency in return for availability and loose coupling. Handle that gap with idempotent compensations, careful step ordering, and countermeasures like semantic locks. Do that, and the saga becomes a reliable backbone for distributed transactions.