What are Vitess and TiKV? CNCF graduated distributed databases
Learn about Vitess, which shards MySQL at YouTube scale with VTGate, VTTablet, topology, and VSchema, and TiKV, the transactional key-value store with Raft and the Percolator model behind TiDB, with a comparison table and a VSchema example.
Kubernetes$ vtctldclient ApplyVSchema --vschema-file vschema.json customer▍Every database grows until the day one machine isn’t enough. Vertical scaling has a ceiling, read replicas don’t help with writes, and partitioning data by hand inside the application becomes technical debt nobody wants to pay. The CNCF has two graduated projects that attack this problem in very different ways: Vitess, which puts a sharding layer in front of MySQL, and TiKV, a distributed key-value database written from scratch.
What Vitess is
Vitess is a database clustering system for horizontally scaling MySQL. It was born at YouTube in 2010 to keep up with the growth of the database behind the site, and was later open-sourced. The application talks to Vitess over the MySQL protocol, as if it were a single server, while behind the scenes the data is spread across several shards, each with a MySQL primary and replicas.
Vitess joined the CNCF as Incubating in February 2018 and has been Graduated since November 2019. That is its status as of November 2026; check the project page. The release marked Latest on GitHub was v24.0.5. Apache 2.0 license.
What TiKV is
TiKV is a distributed, transactional key-value database, written in Rust and created by PingCAP. It is the storage layer of TiDB, a MySQL-compatible distributed SQL database, but it can also be used directly, through a raw API (RawKV) and an ACID transactional API (TxnKV).
TiKV joined the CNCF as Incubating in August 2018 and has been Graduated since September 2020 (status as of November 2026; check the project page). Apache 2.0 license.
What problems they solve
- Vitess: you already have MySQL, the application speaks SQL, and data or write volume has outgrown what one primary can handle. Vitess spreads tables across shards, does connection pooling, protects the database from abusive queries, and allows online resharding, without changing the storage engine.
- TiKV: you need key-value storage with strong consistency and distributed transactions that scales by adding nodes and rebalances itself. Or you use TiDB and want to understand the piece that stores the data.
How Vitess works
| Component | Role |
|---|---|
| VTGate | Lightweight proxy that speaks the MySQL protocol and gRPC, routes each query to the right shards, and merges the results |
| VTTablet | Process next to each mysqld; does pooling, rewrites and limits queries, and handles replication |
| Topology service | Cluster metadata (keyspaces, shards, tablets, each shard’s primary) in etcd, ZooKeeper, or Consul |
vtctld and vtctldclient |
Admin server and client (apply VSchema, reparenting, workflows) |
| VTOrc | Detects replication problems and performs automatic failover |
| VTAdmin | Web UI and admin API |
What ties all of this together is the VSchema. A keyspace is a logical database; if it is sharded, the VSchema says how each table is distributed. The core piece is the vindex, a function that maps a column value to a keyspace ID, which in turn determines the shard. A table’s first vindex is its primary vindex.
One important detail about the topology: there is a global service, with data that rarely changes, and a local one per cell (datacenter or zone), with that cell’s tablets. In the query path, at steady state, Vitess doesn’t call the topology, so a brief outage of it doesn’t take traffic down.
How TiKV works
| Component | Role |
|---|---|
| TiKV server | Stores data in RocksDB, on each node’s local disk |
| Region | A contiguous range of keys; the unit of replication and movement |
| Raft group | Each Region is replicated across several nodes with Raft, which guarantees consistency |
| PD (Placement Driver) | Manages the cluster, balances and moves Regions, and issues transaction timestamps |
Transactions follow a model inspired by Google’s Percolator, with two-phase commit. Each transaction gets a start_ts; in the prewrite phase, it locks every key it will change, and one of them is the primary lock. It then gets a commit_ts and commits the primary: from that moment on, the transaction is committed, even if the secondary locks are cleaned up later. In RocksDB, this becomes three column families: CF_DEFAULT (values), CF_LOCK (locks), and CF_WRITE (commit records).
Vitess vs TiKV
| Criterion | Vitess | TiKV |
|---|---|---|
| What it is | Sharding and orchestration layer on top of MySQL | Distributed, transactional key-value database |
| Application interface | MySQL protocol (SQL) | RawKV and TxnKV APIs; SQL through TiDB |
| Storage | MySQL (InnoDB) in each shard | RocksDB on each node |
| Data distribution | Defined by you in the VSchema (vindexes) | Automatic, by key ranges (Regions) |
| Consistency and replication | MySQL replication, one primary per shard | Raft per Region |
| Cross-shard transactions | Supported, with limitations; ideally model to avoid them | Native, Percolator-inspired model |
| Language | Go | Rust |
| CNCF status (Nov 2026) | Graduated (2019) | Graduated (2020) |
Hands-on example: a VSchema
Picture a customer keyspace sharded by customer_id. The orders table uses the same vindex on the same column, so a customer’s orders live on the same shard as the customer, and a join between them doesn’t cross shards. The customer_id comes from a sequence that lives in an unsharded keyspace called product:
{
"sharded": true,
"vindexes": {
"xxhash": {
"type": "xxhash"
}
},
"tables": {
"customer": {
"column_vindexes": [
{
"column": "customer_id",
"name": "xxhash"
}
],
"auto_increment": {
"column": "customer_id",
"sequence": "product.customer_seq"
}
},
"corder": {
"column_vindexes": [
{
"column": "customer_id",
"name": "xxhash"
}
]
}
}
}
And the VSchema for the product keyspace, which declares the sequence table:
{
"sharded": false,
"tables": {
"customer_seq": {
"type": "sequence"
},
"product": {}
}
}
To apply them, use vtctldclient. Commands as documented officially; --dry-run shows the result without saving it:
vtctldclient ApplyVSchema --vschema-file vschema-product.json product
vtctldclient ApplyVSchema --vschema-file vschema-customer.json --dry-run customer
vtctldclient ApplyVSchema --vschema-file vschema-customer.json customer
On Kubernetes, the usual path is the Vitess operator maintained by PlanetScale; for TiKV (and TiDB), it’s PingCAP’s TiDB Operator. Both use StatefulSets and PVCs underneath, so fast disks and a suitable StorageClass make a difference.
When to use them (and when not to)
Vitess makes sense when:
- You’re already on MySQL and have hit the limit of one primary, but don’t want to rewrite the application for another database.
- The data model has a natural sharding key (customer, tenant, user) and most queries filter on it.
TiKV makes sense when:
- You need key-value storage with transactions and strong consistency that scales horizontally, or you want distributed SQL with TiDB.
Avoid both when:
- The data fits comfortably on a single server with replicas. A distributed database adds components, latency, and new failure modes.
- The team has nobody to operate the extra layer. In that case, a managed service usually costs less effort.
Alternatives
- For MySQL: sharding in the application, or one database per tenant, with more work in the code.
- For distributed SQL: TiDB itself (on top of TiKV) and databases such as CockroachDB and YugabyteDB.
- For key-value: etcd also uses Raft, but it was built for small, critical metadata, such as Kubernetes state, not for large data volumes.
Summary
- Vitess and TiKV are CNCF Graduated projects, under the Apache 2.0 license
- Vitess shards MySQL; the application keeps speaking the MySQL protocol through VTGate
- VTTablet, the topology (etcd, ZooKeeper, or Consul), and VTOrc complete the Vitess architecture
- The VSchema defines vindexes; related tables with the same vindex land on the same shard
- TiKV is a transactional key-value store: Regions replicated with Raft, PD as the cluster’s brain
- TiKV transactions follow a Percolator-inspired model, with prewrite and commit
- A distributed database is the answer to a real scaling problem, not a starting point
Distributing data is easy; distributing data and still sleeping well at night takes picking the right tool for the problem you actually have.