<arch.design/>
Principles/Saga Pattern
SystemArchitectureadvanced1987distributed-transactionscompensationchoreographyorchestration

Saga Pattern

Manage distributed transactions across services using a sequence of local transactions with compensating rollbacks on failure.

3/5
Operates at: System level

System topology — how multiple services are organised

Interactive visualization

Live
Order ServiceCreate Orderorders DBInventory ServiceReserve Stockinventory DBPayment ServiceCharge Paymentpayments DBShipping ServiceCreate Shipmentshipments DBforward transactioncompensating transactionfailure point
Order Serviceidle
Create Orderorders DB
Inventory Serviceidle
Reserve Stockinventory DB
Payment Serviceidle
Charge Paymentpayments DB
Shipping Serviceidle
Create Shipmentshipments DB
All steps succeed — saga completes.

How it works

A Saga is a sequence of local transactions where each step publishes an event or message triggering the next. If a step fails, compensating transactions roll back completed steps.

Two flavours: — Choreography: each service listens for events and reacts, no central coordinator. — Orchestration: a central Saga orchestrator sends commands to each service.

Sagas replace ACID distributed transactions (which don't scale) with eventual consistency + compensation.

Why it matters

Distributed transactions via 2PC are impractical across microservices. The Saga pattern is the standard solution for maintaining data consistency across service boundaries.

When to use

  • Multi-step business transactions spanning multiple services
  • Order processing: reserve inventory → charge payment → ship
  • Any workflow where partial completion needs to be undone

When NOT to use

  • Simple transactions within a single service/database
  • When strong consistency is non-negotiable

Trade-offs

+

No distributed locking — services stay independent

Compensating transactions must be designed and maintained

+

Works across different databases and services

Debugging failures across steps is complex

In production

Amazon

Order workflow: payment → inventory → shipping each as separate steps with compensation

Eventuate.io

Saga orchestration framework widely used in fintech

Industry adoption

3/5Common in specific contexts — used when the problem fits.

Related principles