TiKV
Profile
TiKV is a distributed transactional key-value database written in Rust that provides sub-10ms latency at petabyte scale with strong consistency guarantees. Originally developed by PingCAP as the storage backend for TiDB, it has evolved into a Cloud Native Computing Foundation graduated project serving approximately 1,000 production deployments across e-commerce, fintech, and other industries. Operating under Apache 2.0 license, TiKV combines Raft consensus algorithms with Google Percolator-inspired transaction models to deliver a unified distributed storage layer supporting both raw key-value operations and ACID-compliant distributed transactions, making it suitable for modern cloud-native applications requiring operational and analytical capabilities.
Focus
TiKV addresses the fundamental challenge of storing and processing massive data volumes with strong consistency while maintaining millisecond latency across distributed infrastructure. Traditional relational databases provide consistency but struggle with horizontal scalability, while NoSQL systems offer scalability at the expense of strong consistency and multi-row transactions. TiKV transcends this dichotomy by providing distributed key-value storage supporting both simple low-latency operations and full ACID semantics for complex multi-key transactions. Platform engineers benefit from automatic data distribution, transparent failover, and the ability to scale horizontally without manual sharding, enabling organizations to build systems that maintain consistency guarantees while handling petabyte-scale datasets and millions of concurrent users.
Background
PingCAP created TiKV in 2015 as the distributed storage foundation for TiDB, its distributed SQL database. The project became open source in April 2016 and joined the Cloud Native Computing Foundation as a sandbox project in August 2018, progressing through incubation in April 2019 to graduation status in September 2020. Production adopters include Shopee, Meituan-Dianping, Zhihu, and JD Cloud across sectors spanning e-commerce, food delivery, social networking, and financial services. The project maintains active development with democratic governance through a nine-member steering committee representing PingCAP, JD Cloud & AI, and Yidian Zixun, ensuring distributed decision-making authority beyond single-corporation control.
Main features
Dual API architecture for flexible consistency models
TiKV provides two distinct APIs optimized for different consistency requirements and performance characteristics. The Raw API delivers sub-millisecond average response times with P99 latencies under 10ms for applications requiring simple key-value operations with single-key atomicity, eliminating transactional coordination overhead. The Transactional API implements full ACID semantics across multiple keys using a Percolator-inspired transaction model with snapshot isolation, enabling distributed transactions that maintain consistency when coordinating updates across data items. This architectural separation allows applications to select appropriate consistency guarantees—choosing raw performance for latency-sensitive operations or transactional guarantees for complex multi-key workflows requiring strong consistency.
Automatic data distribution with range-based sharding
TiKV implements automatic data distribution through range-based sharding where continuous key ranges are assigned to partitions called Regions, each described by left-closed, right-open intervals. The Placement Driver component continuously monitors data distribution, automatically splitting Regions exceeding size thresholds and merging small Regions to maintain balanced load without manual intervention. This approach preserves ordered key traversal for efficient range scans while enabling dynamic rebalancing as clusters scale. Each Region replicates across multiple nodes forming Raft groups, with the Placement Driver orchestrating Region placement to ensure even distribution across cluster nodes, transforming complex manual sharding into automated operation.
Raft consensus for strong consistency and fault tolerance
TiKV implements the Raft consensus algorithm to maintain replicated state machines across distributed nodes, ensuring strong consistency despite individual node failures. Raft divides nodes into a single leader servicing client requests and multiple followers receiving replicated write-ahead log entries. Once a quorum acknowledges log entries, the leader commits them, guaranteeing all nodes apply actions to their state machines consistently. Each peer maintains durable write-ahead logs on persistent storage, ensuring recovery to consistent state after power loss or crashes. This architecture provides transparent failover—when leaders fail, followers immediately elect new leaders, resuming request processing after brief election periods while maintaining committed transaction durability.





