Limited Offer

30% OFF Lifetime Access ($139) with code SYSTEM30

TOPIC #88Intermediate 9 min read

The Saga Pattern: Choreography vs Orchestration

💡
Core Architecture Summary

Manage distributed business transactions across microservices using compensating transactions, choreography, and centralized orchestrators.

Key Glossary Concepts in this TopicAll Glossary Terms

01.1. What is the Saga Pattern?

Originally formulated by Hector Garcia-Molina and Kenneth Salem in 1987, a Saga is a sequence of independent local transactions that spans multiple microservices to accomplish a long-lived distributed business workflow.

Unlike Two-Phase Commit (which holds locks across services until the entire distributed transaction completes), each local transaction in a Saga:

  1. Executes locally against its own private database.
  2. Commits its changes immediately in milliseconds.
  3. Publishes a domain event or message to trigger the next step in the workflow.

The Compensating Transaction Mechanism:

If any step in the workflow fails (e.g., inventory is out of stock, or fraud detection flags the account), the Saga cannot execute a traditional database ROLLBACK because preceding steps have already committed.

Instead, the Saga executes a series of Compensating Transactions (C_1, C_2, \dots, C_k) in reverse order that semantically undo the side effects of committed steps (e.g., issuing a credit card refund, un-reserving warehouse stock, sending an apology email).

Saga Compensating Rollback Flow ⏪

PRO Architecture Blueprint

Saga Compensating Rollback Flow ⏪

Failure at step 3 triggers backward compensating transactions across services.

Saga Compensating Rollback Flow ⏪
100%
Rendering visual architecture flowchart...
PRO & LIFETIME CURRICULUM

Unlock Topic #88: The Saga Pattern: Choreography vs Orchestration

You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.

Production Deep Dive

Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.

Interactive Blueprints

Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.

Knowledge Assessment

Staff-level multiple-choice quiz questions with instant feedback and answer explanations.

Cross-Device Progress Sync

Firebase Google authentication automatically syncs your completed topics and quiz scores.

Rate This Architecture Chapter4.9 / 5.0 (38 ratings)

How clear and staff-actionable was this system breakdown?