Orkes logo image
Product
Platform
Orkes Platform thumbnail
Orkes Platform
Orkes Agentic Workflows
Orkes Conductor Vs Conductor OSS thumbnail
Orkes vs. Conductor OSS
Orkes Cloud
How Orkes Powers Boat Thumbnail
How Orkes Powers BOAT
Try enterprise Orkes Cloud for free
Enjoy a free 14-day trial with all enterprise features
Start for free
Capabilities
Microservices Workflow Orchestration icon
Microservices Workflow Orchestration
Enable faster development cycles, easier maintenance, and improved user experiences.
Realtime API Orchestration icon
Realtime API Orchestration
Enable faster development cycles, easier maintenance, and improved user experiences.
Event Driven Architecture icon
Event Driven Architecture
Create durable workflows that promote modularity, flexibility, and responsiveness.
Human Workflow Orchestration icon
Human Workflow Orchestration
Seamlessly insert humans in the loop of complex workflows.
Process orchestration icon
Process Orchestration
Visualize end-to-end business processes, connect people, processes and systems, and monitor performance to resolve issues in real-time
Use Cases
By Industry
Financial Services icon
Financial Services
Secure and comprehensive workflow orchestration for financial services
Media and Entertainment icon
Media and Entertainment
Enterprise grade workflow orchestration for your media pipelines
Telecommunications icon
Telecommunications
Future proof your workflow management with workflow orchestration
Healthcare icon
Healthcare
Revolutionize and expedite patient care with workflow orchestration for healthcare
Shipping and logistics icon
Shipping and Logistics
Reinforce your inventory management with durable execution and long running workflows
Software icon
Software
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean leo mauris, laoreet interdum sodales a, mollis nec enim.
Docs
Developers
Learn
Blog
Explore our blog for insights into the latest trends in workflow orchestration, real-world use cases, and updates on how our solutions are transforming industries.
Read blogs
Check out our latest blog:
Conductor CLI Guide: Register, Run, Retry, and Recover Durable Workflows Without Leaving Your Terminal 💻
Customers
Discover how leading companies are using Orkes to accelerate development, streamline operations, and achieve remarkable results.
Read case studies
Our latest case study:
Twilio Case Study Thumbnail
Orkes Academy New!
Master workflow orchestration with hands-on labs, structured learning paths, and certification. Build production-ready workflows from fundamentals to Agentic AI.
Explore courses
Featured course:
Orkes Academy Thumbnail
Events icon
Events
Videos icons
Videos
In the news icon
In the News
Whitepapers icon
Whitepapers
About us icon
About Us
Pricing
Get a demo
Signup
Slack FaviconDiscourse Logo icon
Get a demo
Signup
Slack FaviconDiscourse Logo icon
Orkes logo image

Company

Platform
Careers
HIRING!
Partners
About Us
Legal Hub
Security

Product

Cloud
Platform
Support

Community

Docs
Blogs
Events

Use Cases

Microservices Workflow Orchestration
Realtime API Orchestration
Event Driven Architecture
Agentic Workflows
Human Workflow Orchestration
Process Orchestration

Compare

Orkes vs Camunda
Orkes vs BPMN
Orkes vs LangChain
Orkes vs Temporal
Twitter or X Socials linkLinkedIn Socials linkYouTube Socials linkSlack Socials linkGithub Socials linkFacebook iconInstagram iconTik Tok icon
© 2026 Orkes. All Rights Reserved.
Back to Blogs

Table of Contents

Share on:Share on LinkedInShare on FacebookShare on Twitter
Worker Code Illustration

Get Started for Free with Dev Edition

Signup
Back to Blogs
SOLUTIONS

Saga Pattern in Distributed Systems

Riza Farheen
Riza Farheen
Developer Advocate
Last updated: July 24, 2023
July 24, 2023
9 min read

Related Blogs

How to Build a Simple, Modular, and AI-Powered Fraud Detection Workflow

Jul 8, 2025

How to Build a Simple, Modular, and AI-Powered Fraud Detection Workflow

Automating Serialization/Deserialization Tests with Orkes Conductor and LLMs

May 29, 2025

Automating Serialization/Deserialization Tests with Orkes Conductor and LLMs

Automating Insurance Claims Processing with AI and Conductor

Apr 24, 2025

Automating Insurance Claims Processing with AI and Conductor

Ready to Build Something Amazing?

Join thousands of developers building the future with Orkes.

Start for free

Distributed systems allow for creating architecture that is easy to maintain and scale. With distributed systems, data management is distributed across multiple services - this is typical of Microservices-based architecture, where a single business use case spans multiple microservices, each with its own local datastore and localized transaction.

A saga pattern is a sequence of such local transactions across multiple services. The Saga Pattern was introduced in 1987 in a paper by Hector Garcia Molina & Kenneth Salem from Princeton University. They defined a saga pattern as a sequence of transactions that can be interleaved with one another.

In this blog, we dive deeper into the concept of the saga pattern and shed light on how Orkes Conductor operates based on this pattern. Orkes Conductor, built over the battle-tested Conductor OSS, is an orchestration platform for building distributed applications and implementing saga patterns for microservices.

Saga Pattern - Orchestration & Choreography

The Saga pattern can be implemented mainly in 2 ways, Orchestration & Choreography.

In a choreography approach, an individual microservice consumes an event and performs the required activity, and passes the event for the next service to consume. There is no centralized coordinator, making communication between the services difficult. But in the orchestration pattern, all the services are linked to the centralized coordinator that orchestrates the services in a predefined order, thus completing the application.

In my previous blog on event-driven architecture, I've discussed Orchestration & Choreography approaches in detail.

Why and When do you implement a Saga Pattern in Your Application Architecture?

The Saga pattern is considered essential in scenarios when:

  • Your application involves multiple steps spanning different services, databases, etc.
  • In situations where a fragmentary execution is not desirable. That is, a rollback is mandatory when one of the services fails.

Compensation Transaction & State Management in Saga Pattern

Several benefits are there while implementing a saga pattern in your application architecture. Let’s have a look at the two main advantages of saga pattern in a microservices architecture:

Compensation Transaction

The Compensation Transaction, a core component of the Saga Pattern, aligns with the “Do It All or Do Nothing" principle. This implies that all the transactions should be completed successfully, or if any service encounters an error, it should be rolled back to the initial state.

If we take the case of a cab booking application, various scenarios, such as the driver and user canceling the trip without proper notification or the payment being declined while the ride is marked as completed, can disrupt the seamless operation of the application. However, these challenges can be addressed by implementing compensation mechanisms for each microservice. These mechanisms help to rectify and resolve such issues, ensuring the smooth functioning of the overall application.

Workflow to handle compensation

In Conductor, the applications are built as workflows. While defining a workflow, you can set a failure/compensation Workflow that will be triggered with the failure of your main workflow. This powerful concept allows developers to build complex compensating workflows that would enable handling database compensations or state management.

Consider the situations where you are booking a cab using an application. The main steps in booking a cab involve:

Sample Illustration for cab booking application

A simplistic model of a cab booking application

When a user searches for a cab, it collects the user's details and initiates the transaction. The next step is to assign a driver for the ride. If no driver is available in the area, then a compensating action should be taken to inform the user.

Now, if the driver is available and confirms the ride, the transaction moves to the next step, which is the payment. The user is prompted to choose the payment method, and if it fails due to any reason, the rollback actions to notify the failed payment or to initiate a refund if the amount was processed should be carried out. Subsequently, the ride should be removed from the driver's list and canceled for the user. All these should work in synchronization for the smooth functioning of the application.

Let’s see how you can create this application using Orkes Conductor.

The sample cab booking application looks like this:

Sample cab booking workflow



The complete code used to define the application is available in the GitHub repository -https://github.com/conductor-sdk/conductor-examples-saga-pattern.

Let’s see how the workflow progresses:

  • The initial booking process is implemented as a series of Simple tasks, which include booking a ride, assigning a driver, making payment & confirming the ride.
  • It is then followed by a fork-join task which handles the notification process. The fork-join task has 2 forks to notify the driver & the user. It is also handled using a Simple task in Orkes Conductor.

Let’s run the application now!

Note: Ensure that you have JDK17 & SQLite installed on your system.

  1. Clone the project locally onto your system.
  2. Update the application.properties file with your access key.
    • If you are using Orkes Developer Edition, refer to this article to get the key and secret.
    • If you are connecting locally, follow the instructions here (Install and Run Locally).
json
orkes.access.key=your_key_id
orkes.access.secret=your_key_secret
orkes.conductor.server.url=https://developer.orkescloud.com/api.

Note: If you are running Conductor locally, replace orkes.conductor.server.url with your Conductor server URL.

  1. Provide permissions for the application to access the workflow and tasks.
  2. By default, conductor.worker.all.domain is set to ‘saga’. Ensure to update with a different name to avoid conflicts with the workflows and workers spun up by others in Orkes Developer Edition.
  3. Run your application from the root project using the following command.
java
mvn spring-boot:run

Next, you need to create a booking request!

You can achieve this in 2 ways,

  • By calling the triggerRideFlow API from within the application.
shell
 curl --location 'http://localhost:8081/triggerRideBookingFlow' \
 --header 'Content-Type: application/json' \
 --data '{
     "pickUpLocation": "150 East 52nd Street, New York, NY 10045",
     "dropOffLocation": "120 West 81st Street, New York, NY 10012",
     "riderId": 1
 }'

Another method is to create the JWT token and then call the Orkes API for executing the workflow.

Once the JWT token is generated, you need to make an HTTP request from Postman/cURL using the following command:

shell
curl --location 'https://developer.orkescloud.com/api/workflow' \
--header "Content-Type: application/json" \
--header 'X-Authorization: <JWT Token>' \
--request POST \
--data '{
    "name": "cab_service_saga_booking_wf",
    "version": 1,
    "input": {
        "pickUpLocation": "250 East 52nd Street, New York, NY 10045",
        "dropOffLocation": "120 West 81st Street, New York, NY 10012",
        "riderId": 1
    },
    "taskToDomain": {
        "*": "saga"
    }
}'

Replace with your JWT token and the required input parameters & your task to domain mapping.

The cab booking application is up and running smoothly! 🚘

Here’s what a compensation action for the cab booking application looks like:

Sample Illustration for cab booking compensation flow

A simplistic model of compensation transaction in a cab booking application

Since there are multiple services with separate databases, a local ACID transaction or the 2PC commit may not be an ideal pattern. Therefore, using the Saga pattern, the cab booking application can ensure that the entire booking process is executed consistently and can be compensated if any step fails.

With Orkes Conductor, while defining a workflow, you can set a failureWorkflow that will be triggered with the failure of your main workflow. In your workflow definition, you can add the workflow name to be run on the failure of your current workflow:

json
"failureWorkflow": "<name of the workflow to be run on failure>",

Here is a sample compensation workflow for the cab booking application we discussed.

Compensation workflow



The cancellation workflow is defined so that relevant steps are taken whenever a corresponding task fails to ensure the rollback of the completed tasks.

Let’s see if the first booking service fails, then the compensation would be triggered like this:

Illustration of original and compensation workflow

Now, suppose due to payment issues, if the workflow fails at the payment service; then the compensation workflow runs like this:

Illustration of original and compensation workflow

Here the payment is canceled in the payment service, followed by removing the driver assignment from the cab assignment service. Finally, the booking is canceled, and the driver is removed from the booking service, along with notifying the driver & user of the same.

Ta-da 🎊! That’s how you roll back the completed services in your application using Orkes Conductor.

Here's a video guide on cab booking app:

State Management

The second main advantage of the saga pattern is state management, which is keeping track of the progress and state of the entire distributed transaction. In distributed applications, failures can occur at any instance; therefore, it is essential to maintain the overall consistency of the transaction.

The saga pattern saves information such as the current step or task being executed, the data associated with the transaction, any compensating actions to be taken in case of failures, and the overall status of the application.

In an orchestrator-based saga pattern, the central orchestrator maintains the application's state. By effectively managing the state in a saga pattern, the system can ensure that complex distributed transactions are executed reliably and that overall data consistency is maintained despite failures.

With Orkes Conductor, the workflow can be queried to get the transaction status at any point and acts as an aggregator across multiple services and their local backend. With its native error-handling capabilities, a strong Orchestrator like Orkes Conductor can be a solution for implementing saga patterns in your distributed applications.

Summing Up

The Saga pattern is efficient for handling distributed transactions in applications with multiple services. With the saga pattern, businesses can ensure data consistency and reliable transaction execution, even in the case of failures.

At Orkes, we offer a powerful orchestration platform, ‘Orkes Conductor’, for building your distributed applications at lightning speed. With Conductor, enterprises can automate their business processes, mitigating potential issues and thus improving overall customer satisfaction.

Whether you’re running a financial institution, healthcare institution, or any business that involves an application with multiple services, implementing the Saga pattern with Orkes Conductor can help streamline your business workflows. Embracing this powerful pattern can improve the overall efficiency of your distributed applications.


Conductor is an enterprise-grade orchestration platform for process automation, API and microservices orchestration, agentic workflows, and more. Check out the full set of features, try it yourself using our Developer Edition sandbox, or get a demo of Orkes Cloud, a fully managed and hosted Conductor service.