Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 15, 2026·3 min de lecture

TiKV — Distributed Transactional Key-Value Store on Raft

A CNCF-graduated distributed key-value store written in Rust that powers TiDB. Provides horizontal scaling, strong consistency via Raft, geo-replication, and ACID transactions with Percolator-style MVCC.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
TiKV Guide
Commande avec revue préalable
npx -y tokrepo@latest install 4772853c-3920-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

TL;DR
TiKV is a Rust-based distributed key-value store that provides ACID transactions and strong consistency via the Raft consensus protocol.
§01

What it is

TiKV is a distributed transactional key-value store written in Rust. It is a CNCF-graduated project that powers TiDB (a distributed SQL database). TiKV provides horizontal scaling, strong consistency via the Raft consensus protocol, geo-replication, and ACID transactions with Percolator-style MVCC.

It targets infrastructure teams building distributed systems that need a reliable storage layer with transactional guarantees. TiKV runs as a standalone key-value store or as the storage engine behind TiDB.

§02

How it saves time or tokens

Building a distributed, strongly consistent storage layer from scratch is a multi-year effort. TiKV provides this as a ready-to-deploy component. The Raft consensus protocol handles leader election and data replication automatically, and the Percolator transaction model provides distributed ACID without manual coordination.

TiKV's RawKV API is simple enough for key-value workloads, while the TxnKV API supports multi-key transactions across shards.

§03

How to use

  1. Install TiUP (PingCAP's cluster manager):
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  1. Start a local TiKV cluster for testing:
tiup playground --mode tikv-slim
  1. Interact with TiKV using the Rust, Go, Java, or Python client:
from tikv_client import RawClient

client = RawClient.connect(['127.0.0.1:2379'])
client.put(b'key1', b'value1')
value = client.get(b'key1')
print(value)  # b'value1'
§04

Example

// Go client example with transactions
package main

import (
    "context"
    "github.com/tikv/client-go/v2/txnkv"
)

func main() {
    client, _ := txnkv.NewClient([]string{"127.0.0.1:2379"})
    txn, _ := client.Begin()

    txn.Set([]byte("account:alice"), []byte("1000"))
    txn.Set([]byte("account:bob"), []byte("500"))

    err := txn.Commit(context.Background())
    // Both writes are atomic -- either both succeed or neither does
}
§05

Related on TokRepo

§06

Common pitfalls

  • TiKV requires PD (Placement Driver) for cluster coordination. Running TiKV without PD is not supported in production.
  • Raft consensus requires an odd number of replicas (3, 5, 7) for proper leader election. A 2-node cluster cannot tolerate any node failure.
  • The Percolator transaction model adds latency compared to single-node databases. Expect 2-5ms per transaction in a well-configured cluster.

Questions fréquentes

What is the relationship between TiKV and TiDB?+

TiDB is a distributed SQL database that uses TiKV as its storage engine. TiKV can also run standalone as a pure key-value store without TiDB. They are separate projects maintained by PingCAP.

What consistency model does TiKV use?+

TiKV provides strong consistency via the Raft consensus protocol. Every write is replicated to a majority of nodes before being acknowledged. Reads can be served from the leader for linearizable consistency or from followers for slightly stale reads.

What programming languages have TiKV clients?+

Official clients are available for Rust, Go, Java, and Python. The Go and Rust clients are the most mature. Community clients exist for other languages.

How does TiKV handle horizontal scaling?+

TiKV automatically splits data into regions (default 96MB each). When a region grows too large, it splits. PD balances regions across TiKV nodes to distribute load evenly.

Is TiKV suitable for time-series data?+

TiKV can store time-series data but is not optimized for it. Dedicated time-series databases like InfluxDB or TimescaleDB provide better compression and query performance for time-series workloads.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires