Introduction
Building a database that operates across multiple geographic regions requires a delicate balance between performance and consistency. To provide strict serializability—the gold standard of consistency—systems like Google Spanner utilize TrueTime Clocks (TTC), which rely on specialized hardware like GPS and atomic clocks to provide timestamps with a known "uncertainty bound."
However, existing co-designs between TTC and databases face significant overhead. Large uncertainty bounds (often around 7ms) force transactions to "commit wait," pausing execution to ensure correct ordering, which severely limits throughput. Furthermore, standard protocols like Two-Phase Locking (2PL) and Two-Phase Commit (2PC) require multiple round-trips across high-latency wide-area networks (WAN), while read-only replicas often suffer from high visibility delays. K2 addresses these challenges by rethinking timestamp generation, transaction ordering, and data visibility across regions.
System Architecture
K2 is designed as a next-generation multi-region data store that "intensely explores" the potential of TrueTime Clocks. The architecture distributes components across geographic regions, utilizing a decentralized approach to transaction management and timestamping.
Core Design Pillars
K2’s design is built upon three core pillars that optimize the interaction between time synchronization and database operations:
1. K2-TB: Timestamp Batching
Instead of equipping every server with expensive TTC hardware, K2 utilizes a TTC Oracle—a small cluster of Precision Time Protocol (PTP) servers in each data center. Ordinary worker nodes request a "batch" of timestamps from this oracle. This approach reduces network overhead and leverages PTP's microsecond-level accuracy to maintain small uncertainty bounds (approximately 400µs), enabling massive scalability of up to $10^5$ timestamps per second per core.
2. K2-MVTO: Multi-Version Timestamp Ordering
K2 moves away from traditional locking mechanisms. It assigns a single timestamp at the start of a transaction, using it for both ordering and versioning. By introducing Write Streams, K2 allows multiple "temporary" writes on a single data item to coexist. This design makes the system fundamentally deadlock-free and eliminates the need for a commit-wait period, as the uncertainty window often passes during the transaction's execution phase.
3. K2-VCR: Visibility Control at Replicas
To minimize staleness at read-only replicas, K2 employs a staggered "epoch" system. Nodes and coordinators collaboratively assign transactions to epochs, ensuring that writes become atomically visible to replica readers without the artificial aborts or long blocking times characteristic of prior systems like CockroachDB or Spanner.
Performance Evaluation
The system was evaluated using TPC-C and YCSB-T benchmarks across a real-world cloud deployment in five geographic regions (including Shanghai, Singapore, and Beijing).
K2 demonstrated significant performance gains, achieving 2.32x higher throughput than MVTO-HLC (a CockroachDB-like protocol) and nearly 10x higher throughput than d2PL-TTC (a Spanner-like protocol). A key factor in this performance is the efficiency of the timestamping mechanism; as shown in the latency breakdown, timestamp acquisition remains a minimal component of total transaction latency even at the 99.9th percentile.
Conclusion
K2 demonstrates that by deeply integrating high-precision clock synchronization with database protocols, it is possible to achieve an order of magnitude higher throughput in geo-distributed environments. While the current implementation relies on PTP infrastructure and asynchronous replication for performance, it sets a new benchmark for how TrueTime Clocks can be leveraged to eliminate traditional bottlenecks in distributed transactions.
Summary updated