ACID, 2PC & Saga Pattern

Maintaining distributed data integrity across microservices using Two-Phase Commit vs. compensating Sagas

Difficulty: Advanced · Read time: 9 min · Access: Step-1 Preview + Knoera Pro

How It Works

Within a single database, ACID (Atomicity, Consistency, Isolation, Durability) guarantees all-or-nothing commits. Across independent microservices and separate databases, Two-Phase Commit (2PC) uses a coordinator to lock rows across all participants before committing—strong consistency, but high latency and blocking risk if the coordinator crashes. The Saga Pattern avoids distributed locks by splitting a workflow into local ACID steps paired with idempotent compensating rollback events.

Why It Matters

In distributed e-commerce or travel booking (Create Order -> Charge Card -> Reserve Inventory), holding row locks via 2PC across external payment gateways kills throughput and stalls whenever one service slows down. Sagas keep microservices decoupled, available, and fault-tolerant.

Interactive Architecture Scenarios

  • Saga Pattern with Compensating Rollback
  • Failure Mode: Two-Phase Commit (2PC) Coordinator Crash

Related Lessons in Databases & Storage Internals