Skip to main content

Distributed Transactions & Idempotency

Difficulty: Hard | Topic #30

What to Learn

Two-phase commit (2PC) and its limitations, Saga pattern (choreography vs orchestration), idempotency keys for safe retries, compensating transactions for rollback, outbox pattern for reliable event publishing.

Resources

Covered by Problems

ProblemDifficultyLink
Online AuctionMedium
Payment SystemHard
Stock Trading Platform (Robinhood)Hard

Key Concepts to Master

  • 2PC coordinator failure and the blocking problem
  • Saga pattern — break a distributed transaction into local transactions with compensating actions
  • Choreography (event-driven) vs orchestration (central coordinator) Sagas
  • Idempotency key stored with the transaction to make retries safe
  • Transactional outbox pattern to atomically write to DB and publish an event