Saga Pattern in System Design: Orchestration vs Choreography

  • Last Updated: November 16, 2026
  • By: javahandson
  • Series
img

Saga Pattern in System Design: Orchestration vs Choreography

Saga pattern explained for system design — orchestration vs choreography, compensating transactions, the pivot step, and the isolation gap, in simple terms.

1. Introduction

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.

2. Why Distributed Transactions Are Hard

Before the saga, let us see the problem it solves. The trouble starts the moment one business action touches more than one database.

2.1 The Comfort of a Single 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.

2.2 The Microservices Problem

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.

3. What Is 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.

3.1 A Chain of Local Transactions

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:

  • It does its work atomically inside one service and one database.
  • The change commits right away, so it is real and durable.
  • Finally, it triggers the next step through an event or a command.

3.2 Compensating Transactions: The Undo Button

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.

3.3 A Simple Order Example

Let us ground this with a familiar flow. Imagine an e-commerce order that moves through three services in order:

  • Order Service — creates the order record.
  • Payment Service — charges the customer’s card.
  • Inventory Service — reserves the items from stock.

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

4. Forward Recovery and Backward Recovery

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.

5. Two Ways to Coordinate a Saga

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.

Saga pattern orchestration vs choreography: a central coordinator directing services versus services reacting to each other's events
Figure 1: Orchestration uses a central coordinator; choreography lets services react to each other’s events.

6. Choreography-Based Saga

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.

6.1 How It Works

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.

6.2 A Walkthrough

Here is how our order flows through a choreographed saga, step by step:

  • Order Service creates the order and publishes an OrderCreated event.
  • Payment Service hears that event, charges the card, and publishes PaymentCompleted.
  • Inventory Service hears PaymentCompleted and tries to reserve stock.
  • On success, it publishes InventoryReserved, and the order is confirmed.
  • On failure, it publishes InventoryFailed, which triggers a refund and an order cancel.

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)

6.3 Benefits of Choreography

  • Simple to start — no extra coordinator service to build or run.
  • Loose coupling — services only know about events, not about each other.
  • No single point of failure — there is no central brain that can crash the whole flow.
  • Good for small sagas — a few participants and a straight-line flow fit it well.

6.4 Drawbacks of Choreography

  • Hard to follow — the logic is scattered across many services.
  • Tough to debug — no single place shows the full saga state.
  • Risk of event tangles — too many events can create confusing cycles.
  • Scales poorly in complexity — adding steps makes the web of events messier.
💡 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.

7. Orchestration-Based Saga

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.

7.1 How It Works

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.

7.2 A Walkthrough

The same order now runs under an orchestrator. Notice how all the decisions sit in one place:

  • The orchestrator sends a Create Order command and waits for success.
  • Next, it sends a Charge Payment command to the Payment Service.
  • Then it sends a Reserve Inventory command to the Inventory Service.
  • If inventory fails, the orchestrator sends Refund Payment and Cancel Order commands.
  • At every step, it records the current state so it can recover after a crash.

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

7.3 Benefits of Orchestration

  • Clear control — one place owns the full workflow and its order.
  • Easy to follow — the whole saga logic lives in the orchestrator.
  • Simpler recovery — compensation rules sit in a single service.
  • Scales with complexity — complex flows with branches stay manageable.

7.4 Drawbacks of Orchestration

  • Extra component — you must build and operate the orchestrator itself.
  • Risk of a bottleneck — every step passes through the coordinator.
  • Possible single point of failure — the orchestrator needs its own resilience.
  • Logic creep — business rules can pile up inside the orchestrator if you are careless.
💡 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.

8. Choreography vs Orchestration: A Quick Comparison

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.

AspectChoreographyOrchestration
ControlSpread across servicesCentral coordinator
CouplingLoose, event-drivenTighter, command-driven
Single point of failureNone by designOrchestrator must be resilient
VisibilityHard to traceClear, one place to look
Best forFew, simple stepsMany or complex steps
DebuggingHarder as it growsEasier 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.

9. Designing Good Compensating Transactions

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.

9.1 Make Them Idempotent

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.

9.2 They May Not Be a Perfect Mirror

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.

9.3 Compensations Can Fail Too

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.

10. The Three Types of Saga Transactions

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.

  • Compensatable transactions — steps that can be undone by a compensating action. Creating an order is one example, since you can cancel it later.
  • Pivot transaction — the go or no-go point of the saga. Once it commits, there is no turning back, so the saga must run forward to the end.
  • Retriable transactions — steps that come after the pivot. They are designed so retries eventually succeed, which supports forward recovery.

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.

11. The Isolation Problem: Sagas Are ACD, Not ACID

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.

11.1 Common Anomalies

  • Dirty reads — one saga reads data that another saga has changed but not yet finished.
  • Lost updates — one saga overwrites a change made by another saga without seeing it.
  • Inconsistent views — a reader sees a mix of old and new values during the flow.

11.2 Countermeasures

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.

  • Semantic lock — the step sets a PENDING flag on the record it touches. The flag warns others that the value may still change. A later step clears it once the saga finishes or rolls back.
  • Commutative updates — design updates so they can run in any order with the same result. A credit and a debit on a balance are a classic example.
  • Pessimistic view — reorder the saga steps to reduce business risk from a dirty read.
  • Reread value — read the record again just before updating it, to catch any change made in between.

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.

12. Reliable Messaging and the Outbox Pattern

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.

13. Saga vs Two-Phase Commit

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.

AspectTwo-Phase CommitSaga Pattern
ConsistencyStrong, immediateEventual
LockingGlobal locks heldNo global locks
AvailabilityLower, blockingHigher, non-blocking
Failure handlingRollback by protocolCompensating transactions
Best fitFew services, strict needsMany services, high scale

14. When to Use (and When to Avoid) the Saga Pattern

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.

14.1 Good Fits

  • A business flow spans several services, each with its own database.
  • You need to undo or compensate when one step in the chain fails.
  • High availability matters more than instant, strict consistency.
  • Long-running processes where holding locks would be impractical.

14.2 Poor Fits

  • Transactions that are tightly coupled and need strict isolation.
  • Flows with cyclic dependencies between the steps.
  • Cases where compensation would have to touch earlier participants in awkward ways.
  • Simple single-service work, where a plain local transaction is enough.

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.

15. Common Mistakes and Interview Insights

A few mistakes show up again and again with sagas. Spotting them early saves hours of debugging later.

  • Forgetting isolation — teams assume ACID behaviour and get surprised by dirty reads. Plan countermeasures from day one.
  • Non-idempotent compensations — a refund that runs twice pays the customer twice. Always make undo actions idempotent.
  • Wrong step order — placing an irreversible action before the pivot breaks clean rollback.
  • Fat orchestrators — stuffing business logic into the coordinator turns it into a hidden monolith.
  • Ignoring message loss — skipping the outbox pattern leaves sagas stuck when events vanish.
  • Over-using sagas — not every flow needs one. A single-service action should stay a simple transaction.

15.1 Interview Insights

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.

16. FAQ’s on saga pattern

Q: What is the saga pattern in simple terms?

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.

Q: What is the difference between orchestration and choreography?

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.

Q: What is a compensating transaction?

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.

Q: Why are sagas called ACD instead of ACID?

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.

Q: What is a pivot transaction in a saga?

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.

Q: Saga pattern vs two-phase commit — which should I use?

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.

17. Conclusion

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.

18. Further Reading

Leave a Comment