Skip to content
Veltoryx Technologies
ProLesson 7.2Intermediate5 min readUpdated 31 October 2026

The Saga Pattern: Choreography vs Orchestration

Coordinate distributed transactions across microservices without blocking Two-Phase Commit using compensating transactions and Saga state machines.

In a monolithic application, maintaining data consistency across multiple database tables is trivial: wrap the business logic in @Transactional, and the relational database handles rollback automatically if an error occurs.

In a microservices architecture with a Database-per-Service pattern, an order checkout spans three independent databases:

  1. Order DB (Stores order status)
  2. Payment DB (Stores customer charges)
  3. Inventory DB (Stores warehouse stock)

How do you guarantee that either all three succeed or all three roll back?

01Why Two-Phase Commit (2PC) Fails in Microservices

Decades ago, enterprise systems used Two-Phase Commit (2PC) coordinated by an XA transaction manager:

  • Phase 1 (Prepare): The coordinator contacts all participant databases and asks: "Can you commit this transaction?" Each database reserves local row locks and votes YES or NO.
  • Phase 2 (Commit): If all voted YES, the coordinator commands all databases to COMMIT.

The Fatal Flaws of 2PC in Modern Cloud

  1. Synchronous Blocking: Row locks are held across remote network boundaries during both phases. If the network hiccups, database locks remain held indefinitely, bringing all other transactions to a halt.
  2. Coordinator as Single Point of Failure: If the transaction coordinator crashes during Phase 2, databases remain frozen waiting for commit instructions.
  3. Incompatible with Modern NoSQL / Message Queues: Databases like MongoDB, Cassandra, and Kafka do not support XA/2PC protocols.
  4. Poor Availability: By the CAP theorem, 2PC is a strict CP protocol; if any single participant goes down, the entire system cannot commit.

Loading the rest of the lesson…