TRT
Sign in
mediumAdvanceddesign

Compare Two-Phase Commit (2PC) vs Saga (Choreography vs Orchestration) for a multi-service checkout or payment transfer. How do you handle Saga Lack of.

Contrast 2PC lock-holding with Saga forward/backward recovery, structure Compensatable -> Pivot -> Retriable steps, apply Semantic Locks (`escrow` / `PENDING`), and compare Multi-Region Cell/Geo-Pinning vs Global Spanner/CockroachDB vs CRDTs.

TRT practice prompt — not a verified question from a named employer.

The Runtime Theory Team2 min read

A strong answer

A strong candidate frames Compare Two-Phase Commit (2PC) vs Saga (Choreography vs Orchestration) for a multi-service checkout or payment transfer. How do you handle Saga Lack of. around the exact memory layout, compiler semantics, and hardware execution model covered in [Distributed Transactions: Two-Phase Commit (2PC) vs Saga Orchestration and Multi-Region Active-Active]. Contrast 2PC lock-holding with Saga forward/backward recovery, structure Compensatable -> Pivot -> Retriable steps, apply Semantic Locks (escrow / PENDING), and compare Multi-Region Cell/Geo-Pinning vs Global Spanner/CockroachDB vs CRDTs.

Your travel booking platform reserves a Flight (Airline Service), charges a Credit Card (Payment Service), and books a Hotel (Hotel Service). An architect proposes using distributed Two-Phase Commit (XA / 2PC) across all three microservices and third-party APIs. In load testing: (1) External APIs (Stripe/Airlines) don't even support XA 2PC locks; (2) Holding row locks across network round-trips drops database throughput by 20x; and (3) When the Coordinator pod crashes after Phase 1 (PREPARE) succeeds, the participants' database rows remain locked and blocked indefinitely until the Coordinator recovers!

When engineers encounter this bottleneck in production, a surface-level API description rarely explains what went wrong. In real workloads, every line of code executes against concrete hardware constraints: fixed-width memory cells, CPU cache lines, kernel descriptor tables, network socket buffers, or accelerator memory buses. Without a clear mental model of Two-Phase Commit (2PC) vs Saga Orchestration (Forward Recovery & Compensating Transactions) and Multi-Region Routing, debugging degrades into guesswork—tuning timeouts, adding retries, or scaling instances blindly while the underlying architectural flaw remains untouched.

In a production interview, always connect the specification rule to its concrete runtime consequence: state what lives on the stack versus the heap or static storage segment, how the compiler or operating system validates alignments, lifetimes, and error codes, and what happens under adversarial or boundary inputs (such as zero-length buffers, integer overflow, concurrent mutation, or partial I/O). Backing your explanation with a small trace of register/memory state transitions immediately separates senior systems engineers from candidates who only memorized syntax.

What the interviewer is listening for

  • Mastery of core invariant: Explain why Two-Phase Commit (2PC) is a blocking protocol that degrades database concurrency across microservices.
  • Mastery of core invariant: Design a Saga Orchestrator structured into Compensatable, Pivot, and Retriable steps with Semantic Locks for isolation.
  • Mastery of core invariant: Architect Multi-Region Active-Active systems using Home-Region Geo-Pinning, local Raft quorums, and asynchronous cross-region DR.
  • Hardware and ABI awareness: Explaining how sizes, alignments, calling conventions, or kernel boundaries behave on real 64-bit targets rather than relying on implementation-defined assumptions.
  • Defensive engineering: Naming the exact compiler flags (-Wall -Wextra -Werror), static analyzers, or runtime sanitizers (-fsanitize=address,undefined,thread) that verify correctness in CI.

Common mistakes

  • Explaining only surface syntax without tracing the underlying memory addresses, ownership lifetime, or kernel/user-space state transitions.
  • Assuming undefined behavior (such as signed overflow, uninitialized reads, strict-aliasing violations, or dangling pointers) will "just work" because it passed an unoptimized -O0 debug build.
  • Ignoring return codes, partial reads/writes, alignment padding, or cleanup paths when an allocation or syscall fails midway through a function.

This answer walks

Practice follow-ups

  1. 01In a Multi-Region Active-Active system (US-East and EU-West), why is **Geo-Sharding / Home-Region Pinning** (pinning each user or tenant's writes to their home region with local Raft quorum in 2 ms.
  2. 02When should you choose Saga **Orchestration** (central state machine / Temporal) over Saga **Choreography** (services listening to each other's events)?

Not started

Sign in to save your learning progress.

Sign in to save