Home▸Articles▸Computer Science

Saga Pattern 2D: Distributed Transactions Across Microservices

A fundamental technique for managing complex transactions in distributed systems, ensuring consistency even when individual services fail.

mysimulator teamUpdated June 2026≈ 3 min read▶ Open the simulation

What is the Saga Pattern?

The saga pattern is a method for managing distributed transactions in systems composed of microservices. Each service performs its part of the transaction, but if any step fails, subsequent steps are rolled back to maintain consistency. This approach allows for complex workflows that span multiple services without requiring all services to be tightly coupled.

In essence, a saga consists of a sequence of compensating actions (or 'saga steps') that can undo previous actions if an error occurs during the transaction.

How Does It Work?

Each service in a saga pattern maintains its own local state and communicates with other services through asynchronous messages. When a transaction is initiated, each step of the saga is executed sequentially. If any step fails, the entire transaction is rolled back by executing compensating actions that undo the effects of previous steps.

This approach ensures that if one service fails or experiences an error, the overall transaction can still be completed correctly by reverting to a consistent state.

live demo · related simulation● LIVE

Why Use Saga Pattern?

The saga pattern is particularly useful in distributed systems where services may fail independently. It allows for complex workflows that span multiple services without the need for a centralized transaction manager, which can be a single point of failure.

Moreover, it provides better fault tolerance and scalability compared to traditional two-phase commit protocols.

Orchestrated vs. Choreographed Coordination

In orchestrated saga patterns, a central orchestrator manages the sequence of steps and coordinates between services. This approach ensures that each step is executed in the correct order but can introduce additional complexity and latency.

Choreographed sagas rely on services to coordinate with each other directly without a central coordinator. While this reduces overhead, it requires more complex error handling and coordination logic.

Frequently asked questions

What is the difference between orchestrated and choreographed sagas?

Orchestrated sagas use a central orchestrator to manage the sequence of steps and coordinate between services, while choreographed sagas rely on services to coordinate directly with each other.

Why might I choose one over the other?

Orchestrated sagas are easier to implement but can introduce additional latency and complexity. Choreographed sagas reduce overhead but require more complex error handling and coordination logic.

How does the failure probability affect saga success rates?

The success rate of a saga decreases exponentially with each step, as the probability of failure for all steps must be successful to complete the transaction. This is represented by (1-p)^n where p is the per-step failure probability and n is the number of steps.

What does the strip chart show?

The strip chart shows the success rate of sagas over time, allowing you to compare orchestrated versus choreographed coordination methods under different failure scenarios.

Try it live

Everything above runs in your browser — open Saga Pattern 2D: Distributed Transactions Across Microservices and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Saga Pattern 2D: Distributed Transactions Across Microservices simulation

What did you find?

Add reproduction steps (optional)