Stackbook Logo
data-consistencyestablished · high operational burden

Saga Patterns (Choreography vs Orchestration)

Also known as: distributed-saga, choreography-saga, orchestration-saga, saga-orchestrator

Intent

Manage distributed transactions across services without 2PC, using choreography (events) or orchestration (central coordinator) with compensating actions.

Problem

Cross-service operations need atomicity. 2PC unavailable/slow. Sagas provide eventual consistency with compensation.

Forces

  • Services own data; no distributed transaction coordinator
  • Operations span multiple services (order → payment → inventory → shipping)
  • Partial failure requires rollback of completed steps
  • Compensating actions must be idempotent and retryable

Solution

✓ When to Use

  • Long-running business processes across service boundaries
  • When eventual consistency is acceptable (seconds to minutes)
  • When 2PC is unavailable or undesirable

✗ When Not to Use

  • Short-lived operations where synchronous ACID works
  • When strong consistency is required (financial ledger)
  • Simple two-service calls (use outbox + idempotency instead)

Pros

  • +No distributed lock; services remain autonomous
  • +Works with any transport (HTTP, message queue, event bus)
  • +Visible business process; each step auditable
  • +Compensation logic explicit, testable

Cons

  • Eventual consistency — temporary inconsistent states visible
  • Compensation logic complexity (partial failure handling)
  • Testing: must verify all failure paths and compensations
  • Choreography: implicit flow, hard to trace; Orchestration: central coupling

Cost Profile

Infrastructure

Low — uses existing messaging

Operational

High — monitor saga state, handle stuck sagas

Cognitive

High — compensation design, failure mode analysis

Failure Modes

  • Compensation fails → saga stuck, manual intervention needed

  • Race conditions: concurrent sagas on same entities

  • Timeouts: step takes too long, orchestrator triggers compensation prematurely

  • Lost events: choreography breaks if event not delivered

Real-World Examples

Alternatives

  • 2pc
  • event-sourcing
  • outbox-pattern
  • transactional-outbox

Related Patterns

  • outbox-pattern
  • idempotency-key
  • event-sourcing
  • compensating-transaction
  • orchestration
  • choreography

Competency Domains

data consistencydata statedistribution communicationreliability opseconomics evolution