Catalog
concept#Product#Delivery#Compensation#Eventual Consistency

Saga Pattern

The Saga pattern coordinates distributed transactions across multiple services by composing local transactions with compensations to maintain overall consistency.

The Saga pattern is an architectural concept for distributed systems that models a business workflow as a sequence of local transactions.
Established
High

Classification

  • High
  • Technical
  • Architectural
  • Intermediate

Technical context

Event busWorkflow engineDistributed tracing

Principles & goals

Local transactions are the unit of workCompensations must be deterministicEventual consistency is explicitly accepted
Build
Enterprise

Use cases & scenarios

Compromises

  • Incomplete compensations create inconsistencies
  • Duplicate execution due to retries
  • Distributed deadlocks from faulty choreography
  • Use idempotent handlers
  • Persist saga state
  • Build end-to-end observability

I/O & resources

  • Business process steps
  • Compensation logic
  • Service interfaces
  • Consistent overall state
  • Compensation events
  • Auditable execution trail

Description

The Saga pattern is an architectural concept for distributed systems that models a business workflow as a sequence of local transactions. Each local transaction commits independently and triggers compensating actions on failure to restore overall state. This enables eventual consistency without a central, blocking two‑phase commit.

  • No global lock or 2PC required
  • Scales across service boundaries
  • Failures can be handled via compensation

  • Complex failure and compensation logic
  • Only eventual consistency
  • Higher observability requirements

  • Compensation rate

    Share of sagas that require compensation.

  • End-to-end duration

    Time to complete a saga.

  • Step failure rate

    Share of failed local transactions per step.

E‑commerce checkout

Payment, inventory, and shipping are modeled as saga steps with compensations on failure.

Booking platform

Flight, hotel, and car rental are local transactions that are compensated on conflicts.

Account migration

User accounts, subscriptions, and permissions are migrated stepwise with compensations on errors.

1

Decompose the process into local transactions

2

Define compensation paths

3

Choose orchestration or choreography

⚠️ Technical debt & bottlenecks

  • Inconsistent compensation logic
  • Manual intervention for saga failures
  • Missing restart strategies
Compensation designObservabilityEvent flows
  • Using sagas for strictly consistent financial postings
  • Compensation without idempotency
  • Choreography without clear event contracts
  • Forgetting side effects in compensation
  • Missing timeouts and retries
  • Insufficient visibility of saga state
Domain-driven designEvent-driven architectureResilience patterns
Service decouplingScalabilityResilience to partial failures
  • Strict compliance requirements
  • Service boundaries are fixed
  • Limited transaction windows