# Tikv
__*TiKV features*__
+ Persistent data
+ Distributed transaction support
+ Strong consistency and high availability of replicas
+ **MVCC** (multi-version concurrency control)
+ **Coprocessor** (operator push down)

![center](./student-guide/diagram/TiKV_aa_001_20220506.png)

------------------------------------------------------------
We will introduce you in detail the main functions and implement principles of TiKV. Let us take a brief look at its various functions.

1. Persistent data
TiKV chose the RocksDB engine based on the LSM-tree data structure as the data persistence storage engine, while the RocksDB engine uses mechanisms such as WAL to ensure that data is not lost, that is, persistence.

2. Distributed transaction support
In the 2-phase commit process of the TiDB database based on the Percolator transaction model, the storage lock space is allocated separately on each TiKV, called CF Lock (column cluster), so that a decentralization 2-phase commit is realized in conjunction with the global TSO timing of TiDB Server and PD.
In addition, the TiDB database also supports two locking modes: optimistic locking and pessimistic lock, and after the TiDB 5.0 version, the asynchronous commit function of the second stage of the 2-phase commit is realized. In the OLTP scenario, the write delay is greatly reduced. Introduction.

3. Strong consistency and high availability of multiple replicas
The TiKV cluster adopts the Multi-Raft mechanism to achieve strong consistency and high availability of multiple replica. At the same time, the Regions stored in TiKV are automatically split and merged to achieve dynamic scale. Finally, the region in TiKV of the PD node can be flexibly scheduled, avoiding the common use of distributed databases such as hotspots problem.

4. MVCC (multi-version concurrency control)
MVCC (Multiple Version Concurrency Control) is essential for database high concurrent reads and writes requirements. It is the basis for implement functions such as concurrency control, SI isolation level, distributed transaction, and fast data recover. TiKVs MVCC implement is done by adding a version number after the Key, and after the historical version data reaches a certain period of time, it is cleaned up by the TiDB Server for garbage collection (GC).

5. Coprocessor (operator push down)
The Coprocessor function enables TiKV to perform data filtering, partial aggregation, etc. on the local node, so that SQL calculation can be pushed down to distributed storage nodes to complete it. This mechanism not only reduces network interaction costs, but also makes full use of the computing resources (CPU, cache, and memory) of TiDB Server, and also makes full use of distributed storage nodes Parallel processing power.