• Stars
    star
    14,447
  • Rank 1,954 (Top 0.04 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Distributed transactional key-value database, originally created to complement TiDB

tikv_logo

Build Status Coverage Status CII Best Practices

TiKV is an open-source, distributed, and transactional key-value database. Unlike other traditional NoSQL systems, TiKV not only provides classical key-value APIs, but also transactional APIs with ACID compliance. Built in Rust and powered by Raft, TiKV was originally created by PingCAP to complement TiDB, a distributed HTAP database compatible with the MySQL protocol.

The design of TiKV ('Ti' stands for titanium) is inspired by some great distributed systems from Google, such as BigTable, Spanner, and Percolator, and some of the latest achievements in academia in recent years, such as the Raft consensus algorithm.

If you're interested in contributing to TiKV, or want to build it from source, see CONTRIBUTING.md.

cncf_logo cncf_logo

TiKV is a graduated project of the Cloud Native Computing Foundation (CNCF). If you are an organization that wants to help shape the evolution of technologies that are container-packaged, dynamically-scheduled and microservices-oriented, consider joining the CNCF. For details about who's involved and how TiKV plays a role, read the CNCF announcement.


With the implementation of the Raft consensus algorithm in Rust and consensus state stored in RocksDB, TiKV guarantees data consistency. Placement Driver (PD), which is introduced to implement auto-sharding, enables automatic data migration. The transaction model is similar to Google's Percolator with some performance improvements. TiKV also provides snapshot isolation (SI), snapshot isolation with lock (SQL: SELECT ... FOR UPDATE), and externally consistent reads and writes in distributed transactions.

TiKV has the following key features:

  • Geo-Replication

    TiKV uses Raft and the Placement Driver to support Geo-Replication.

  • Horizontal scalability

    With PD and carefully designed Raft groups, TiKV excels in horizontal scalability and can easily scale to 100+ TBs of data.

  • Consistent distributed transactions

    Similar to Google's Spanner, TiKV supports externally-consistent distributed transactions.

  • Coprocessor support

    Similar to HBase, TiKV implements a coprocessor framework to support distributed computing.

  • Cooperates with TiDB

    Thanks to the internal optimization, TiKV and TiDB can work together to be a compelling database solution with high horizontal scalability, externally-consistent transactions, support for RDBMS, and NoSQL design patterns.

Governance

See Governance.

Documentation

For instructions on deployment, configuration, and maintenance of TiKV,see TiKV documentation on our website. For more details on concepts and designs behind TiKV, see Deep Dive TiKV.

Note:

We have migrated our documentation from the TiKV's wiki page to the official website. The original Wiki page is discontinued. If you have any suggestions or issues regarding documentation, offer your feedback here.

TiKV adopters

You can view the list of TiKV Adopters.

TiKV software stack

The TiKV software stack

  • Placement Driver: PD is the cluster manager of TiKV, which periodically checks replication constraints to balance load and data automatically.
  • Store: There is a RocksDB within each Store and it stores data into the local disk.
  • Region: Region is the basic unit of Key-Value data movement. Each Region is replicated to multiple Nodes. These multiple replicas form a Raft group.
  • Node: A physical node in the cluster. Within each node, there are one or more Stores. Within each Store, there are many Regions.

When a node starts, the metadata of the Node, Store and Region are recorded into PD. The status of each Region and Store is reported to PD regularly.

Quick start

Deploy a playground with TiUP

The most quickest to try out TiKV with TiDB is using TiUP, a component manager for TiDB.

You can see this page for a step by step tutorial.

Deploy a playground with binary

TiKV is able to run separately with PD, which is the minimal deployment required.

  1. Download and extract binaries.
$ export TIKV_VERSION=v4.0.12
$ export GOOS=darwin  # only {darwin, linux} are supported
$ export GOARCH=amd64 # only {amd64, arm64} are supported
$ curl -O  https://tiup-mirrors.pingcap.com/tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ curl -O  https://tiup-mirrors.pingcap.com/pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
  1. Start PD instance.
$ ./pd-server --name=pd --data-dir=/tmp/pd/data --client-urls="http://127.0.0.1:2379" --peer-urls="http://127.0.0.1:2380" --initial-cluster="pd=http://127.0.0.1:2380" --log-file=/tmp/pd/log/pd.log
  1. Start TiKV instance.
$ ./tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20160" --data-dir=/tmp/tikv/data --log-file=/tmp/tikv/log/tikv.log
  1. Install TiKV Client(Python) and verify the deployment, required Python 3.5+.
$ pip3 install -i https://test.pypi.org/simple/ tikv-client
from tikv_client import RawClient

client = RawClient.connect("127.0.0.1:2379")

client.put(b'foo', b'bar')
print(client.get(b'foo')) # b'bar'

client.put(b'foo', b'baz')
print(client.get(b'foo')) # b'baz'

Deploy a cluster with TiUP

You can see this manual of production-like cluster deployment presented by @c4pt0r.

Build from source

See CONTRIBUTING.md.

Client drivers

If you want to try the Go client, see Go Client.

Security

Security audit

A third-party security auditing was performed by Cure53. See the full report here.

Reporting Security Vulnerabilities

To report a security vulnerability, please send an email to TiKV-security group.

See Security for the process and policy followed by the TiKV project.

Communication

Communication within the TiKV community abides by TiKV Code of Conduct. Here is an excerpt:

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

Social Media

Slack

Join the TiKV community on Slack - Sign up and join channels on TiKV topics that interest you.

License

TiKV is under the Apache 2.0 license. See the LICENSE file for details.

Acknowledgments

  • Thanks etcd for providing some great open source tools.
  • Thanks RocksDB for their powerful storage engines.
  • Thanks rust-clippy. We do love the great project.

More Repositories

1

raft-rs

Raft distributed consensus algorithm implemented in Rust.
Rust
2,785
star
2

grpc-rs

The gRPC library for Rust built on C Core library and futures
Rust
1,775
star
3

pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Rust
1,198
star
4

pd

Placement driver for TiKV
Go
1,022
star
5

rust-prometheus

Prometheus instrumentation library for Rust applications
Rust
1,017
star
6

agatedb

A persistent key-value storage in rust.
Rust
793
star
7

minitrace-rust

Extremely fast tracing library for Rust
Rust
659
star
8

raft-engine

A persistent storage engine for Multi-Raft log
Rust
521
star
9

titan

A RocksDB plugin for key-value separation, inspired by WiscKey.
C++
466
star
10

client-rust

Rust Client for TiKV.
Rust
364
star
11

fail-rs

Fail points for rust
Rust
322
star
12

jemallocator

Rust allocator using jemalloc as a backend
Rust
298
star
13

client-go

Go client for TiKV
Go
268
star
14

minstant

Performant time measuring in Rust
Rust
151
star
15

yatp

Yet another thread pool in rust for both callbacks or futures.
Rust
129
star
16

client-java

TiKV Java Client
Java
106
star
17

deep-dive-tikv

How do we build a distributed, transactional key-value database - TiKV?
HTML
97
star
18

rfcs

RFCs for changes to TiKV and its ecosystem
76
star
19

auto-tikv

Tool to tune TiKV with ML method
Python
66
star
20

sig-transaction

Resources for the transaction SIG
61
star
21

async-speed-limit

Asynchronously speed-limiting multiple byte streams
Rust
53
star
22

minitrace-go

A high-performance timeline tracing library for Golang, used by TiDB
Go
45
star
23

community

TiKV community content
43
star
24

client-c

The C++ TiKV client used by TiFlash.
C++
41
star
25

crc64fast

SIMD accelerated CRC-64-ECMA computation
Rust
40
star
26

migration

Migration tools for TiKV, e.g. online bulk load.
Go
34
star
27

tikv-dev-guide

The TiKV development/contribution guide
34
star
28

client-py

Rust
27
star
29

website

Website for tikv.org
HTML
20
star
30

importer

tikv-importer is a front-end to help ingesting large number of KV pairs into a TiKV cluster
Rust
20
star
31

tikv-operator

Go
19
star
32

protobuf-build

Rust
18
star
33

client-cpp

TiKV Client for C++
Rust
15
star
34

client-node

Rust
11
star
35

mur3

Rust implementation of MurmurHash3.
Rust
10
star
36

copr-test

Go
9
star
37

mock-tikv

A mocked TiKV server for testing clients that written in different languages.
Go
6
star
38

slog-global

Global loggers for slog-rs. Similar to slog-scope but more simple.
Rust
5
star
39

match-template

match-template is a procedural macro that generates repeated match arms by pattern.
Rust
5
star
40

jepsen-test

Clojure
5
star
41

terraform-tikv-bench

An Orcestrated TiKV benchmark. Not for production deployment.
HCL
4
star
42

skiplist-rs

Rust
4
star
43

client-validator

Provide functional checks for tikv client implementations in different languages.
Go
3
star
44

tracing-active-tree

Rust
3
star
45

tlaplus-specs

TiKV TLA+ specifications
TLA
3
star