openskills.info
TiKV logoCourse Preview

TiKV

TiKV is a distributed key-value database that splits ordered keys across a cluster and replicates each range. It gives applications a durable storage layer with raw key-value access or distributed transactions.

itCloud native tools and technologies

Don't Panic — TiKV

TiKV is a database for keeping an ordered collection of byte keys and values on several machines without asking the application to memorize where each key moved to this morning. That last part is doing a remarkable amount of work. A single machine can keep an ordered map without convening a committee. A cluster must decide where each part lives, which copy speaks first, and when a write counts as real.

TiKV handles this by cutting one key space into Regions: consecutive ranges of keys. Each Region has several copies, called peers. The peers form a Raft group, and one peer is the leader. A write visits that leader, becomes a Raft log entry, and is committed when a majority agrees. This is less like putting copies in a filing cabinet and more like having the filing cabinet insist on a quorum before it changes a label.

PD, short for Placement Driver, keeps the wider map. It knows about Stores, Regions, leaders, capacity, and topology. Raft keeps one Region's replicas consistent; PD decides how many Regions should be where. That distinction is the useful bit. A system can have correct replicas in each small group and still need help distributing leaders, making room on a new Store, or avoiding a crowded part of the cluster.

The first surprise is that adding a Store also creates work. PD moves Regions and leaders toward the new layout, and those moves consume disk, network, and CPU. Replication also does not turn every network partition into a writable party. A quorum is a majority, so the minority side stops accepting safe writes. Backups and restore tests remain necessary, because no amount of orderly agreement recreates data you never recovered.

TiKV offers two ways to speak to the data. RawKV is direct key-value access with single-key atomicity. TxnKV adds multi-key ACID transactions and MVCC, which lets a transaction read a consistent snapshot and detects conflicting updates when it commits. The important decision is not which acronym sounds more expensive. It is whether several keys must change together. Separate RawKV operations do not become a transaction by wishing very earnestly.

Continue with the Intro for the architecture and the limits that follow from quorum. The Slides make the write path and the TiDB relationship visible at a glance. The Cheatsheet is the compact map for Regions, PD, Raft, RawKV, TxnKV, and monitoring signals. Field Notes covers the production judgments that hide behind the tidy diagram: hot keys, Region count, rebalancing, transaction retries, and Raftstore pressure.

Where this skill leads

Relevant careers

See how this topic contributes to broader role-level skill maps.

Sources