Skip to content
StackDecode
System Design
9. Message Queues and Event-Driven Systems11. Microservices ArchitectureAnimated

Saga Pattern

A chain of local transactions with compensations.

The idea

Instead of one distributed transaction, each step commits locally and failures trigger compensating actions.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

OrchestratorOrderPaymentInventorycreate order
  • current message
  • earlier
  • failure or attack

The orchestrator drives each local transaction in turn.

step:
1/8
from:
Orchestrator
to:
Order
1/8

Time runs downward. Solid arrows are requests, dashed arrows are replies.

Step by step

  1. 1Step 1 commits
  2. 2Step 2 commits
  3. 3If a step fails run compensations
  4. 4The system returns to a consistent state

Where it is used

Cross-service workflows.

Watch out for

Compensation logic is complex and temporary states are visible.

Related