TL;DR
Distributed databases spanning the globe suffer from massive performance penalties due to the slow speed of light traveling between distant datacenters. This paper introduces Decentralized Two-Phase Commit (D2PC), a protocol that cuts transaction commit latency by 43% and boosts throughput by up to 2.43×. It achieves this by decentralizing the transaction coordinator and running the commit protocol in parallel with consensus replication, allowing databases to release data locks much faster.
What Problem Does This Paper Address?
Modern globally distributed databases (like Google Spanner or CockroachDB) split and replicate data across datacenters worldwide to survive regional disasters and serve local users quickly. However, writing data across these regions is notoriously slow.
To ensure that a transaction either commits everywhere or nowhere, databases typically use a Two-Phase Commit (2PC) protocol layered on top of a consensus protocol (like Paxos or Raft). This traditional architecture suffers from two major flaws:
- High Commit Latency: Transactions must endure multiple cross-region network round-trips (RTTs) to collect votes and replicate logs before finishing.
- Long Concurrency Control Periods: Because cross-region communication takes time, data locks are held for a long duration. Under heavy workloads, this causes severe data contention, blocking other transactions and tanking system throughput.
Methods
The authors propose D2PC, which optimizes the traditional layered database architecture without requiring a complete overhaul of the underlying storage engine. D2PC introduces three main mechanisms:
- Decentralized Co-coordinators: Instead of relying on a single central coordinator node, D2PC deploys a "co-coordinator" in every datacenter. These co-coordinators work in parallel to collect votes from local replicas.
- Process Decoupling: D2PC breaks the strict hierarchy of traditional systems by running 2PC vote collection and consensus replication concurrently rather than sequentially.
- PreCommit State & Early Lock Release: Once local co-coordinators gather votes, they make a swift
PreCommitdecision in just 0.5 RTT. Shard leaders can then release locks early, making updates visible to subsequent transactions before global replication is fully complete. To prevent dirty reads, D2PC tracks write-read dependencies using a memory-basedPreCommitlist. - Bypass Leader Replication Reply: Followers send replication acknowledgments directly to their local co-coordinator, which forwards them to the main coordinator. Bypassing the shard leader shaves off an entire cross-region network hop during the final commit phase.
Datasets
The authors evaluated D2PC using two standard database transaction benchmarks:
- Retwis: A synthetic benchmark that simulates the backend of a Twitter-like social network, featuring workloads like adding users, posting tweets, following/unfollowing, and generating timelines.
- YCSB+T: An extension of the Yahoo! Cloud Serving Benchmark (YCSB) that adds transactional support, allowing the authors to test multi-shard transactions under highly customizable data contention levels.
Key Insights and Ideas
- Parallelism Over Layering: Traditional systems treat consensus and transaction atomicity as strictly isolated, hierarchical layers. D2PC proves that these processes are logically independent and can be safely parallelized to eliminate redundant network delays.
- Exploiting Local Co-location: By placing a co-coordinator in every region, slow cross-region round-trips are converted into fast, intra-datacenter hops. Followers can instantly update their local co-coordinator, which aggregates data before sending it across the ocean.
- Safe Early Visibility: You don't need to wait for data to be safely written on the other side of the planet to release a lock. Once the global serial order of transactions is locked in (at the
PreCommitstage), it is safe to let other transactions read the uncommitted data, provided you track dependencies to cascade-abort them in the rare event of a total replication failure.
Key Results
The authors evaluated D2PC across a multi-cloud testbed spanning five global regions (including China, the US, and Europe):
- Throughput Gains: When paired with Optimistic Concurrency Control (OCC), D2PC improved throughput by up to 2.43× compared to standard 2PC+OCC. When paired with Two-Phase Locking (2PL), it achieved a 2.33× improvement.
- Latency Reduction: D2PC reduced transaction commit latency by 43% under standard configurations.
- Contention Resilience: Under high data contention (simulated via a high Zipf coefficient), D2PC significantly outperformed both traditional 2PC and leaderless "co-designed" protocols like Carousel. This is because D2PC maintains an ultra-short 0.5 RTT lock-holding window, preventing the system from thrashing due to conflicts.
Limitations and Future Work
- Dependency Tracking Overhead: Releasing locks early requires maintaining a
PreCommitlist in memory to track write-read dependencies. If a transaction aborts late in the replication phase, it can trigger cascade aborts of dependent transactions, though the authors note this is rare in practice. - Co-coordinator Bottlenecks: Because co-coordinators handle all transactions in a datacenter, they can become CPU/memory bottlenecks under extreme loads. While the authors proposed a basic sharding strategy to mitigate this, further optimization is needed for massive-scale deployments.
Summary updated