Course contentsShow
← System Design
Lesson 575 of 1,91916. Distributed TransactionsFree lesson

2PC Performance Characteristics

Understanding latency impact: 2 network round-trips and synchronous disk writes.

2PC Performance Characteristics

What you'll learn: Why Two-Phase Commit is slow and what performance costs you pay for distributed transaction guarantees.

The Speed Tax of Distributed Consistency

Two-Phase Commit gives you strong ACID guarantees across multiple nodes, but it comes with significant performance overhead. Understanding these costs helps you decide when 2PC is worth it.

The Two Major Performance Bottlenecks

1. Network Round-Trips

2PC requires two complete network round-trips for every transaction:

  • Prepare Phase: Coordinator sends prepare messages to all participants, waits for all responses
  • Commit Phase: Coordinator sends commit/abort messages, waits for acknowledgments

This is like having a meeting where everyone must respond twice before anything happens. If you have 5 participants across different data centers, that's 10+ network messages per transaction. Network latency multiplies with distance and participant count.

2. Synchronous Disk Writes

Both coordinator and participants must perform synchronous disk writes at critical points:

  • Participants flush their prepare vote to disk before responding
  • Coordinator flushes the final decision to disk before announcing it
  • Participants flush the final outcome to disk

These writes are synchronous (blocking) because they're essential for recovery. If a node crashes, it must read these logs to know what to do. Disk I/O is orders of magnitude slower than memory operations—typically milliseconds instead of microseconds.

The Compounding Effect

These two factors compound: you're waiting on the slowest participant's disk write, then waiting for network round-trips, then waiting again. A transaction that would take microseconds locally can take tens or hundreds of milliseconds distributed.

This is why 2PC throughput is often measured in hundreds of transactions per second, not thousands.

Key Takeaway: 2PC trades performance for correctness—expect 2 network round-trips and multiple synchronous disk writes per transaction, making it significantly slower than non-transactional operations.