Distributed Transactions Across Services: 2PC vs Sagas vs TCC
Coordinate state across isolated service databases: XA/2PC blocking limits, Choreography/Orchestration Sagas, and Try-Confirm-Cancel (TCC).
01.1. Why Traditional ACID Fails Across Microservices
In a single monolithic database, atomic transactions are guaranteed by database engine primitives (BEGIN ... COMMIT / ROLLBACK).
When microservices each own their private databases, a business process (such as e-commerce checkout) involves mutating data across 3 separate physical databases:
- Order Database (PostgreSQL): Insert row in
orderstable. - Payment Database (MySQL): Record credit card authorization in
charges. - Inventory Database (DynamoDB): Decrement quantity in
stock.
If the payment succeeds but the inventory decrement fails, the system is in an inconsistent state (customer was charged, but the item cannot be shipped). Microservices require distributed transaction coordination patterns.
Saga Orchestration with Compensating Transactions π
Saga Orchestration with Compensating Transactions π
When a step in the distributed transaction fails, the orchestrator triggers compensating backward rollbacks to restore system consistency.
Unlock Topic #147: Distributed Transactions Across Services: 2PC vs Sagas vs TCC
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.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?