# Raft Vs. Multi Raft


![left](./student-guide/diagram/03-Raft-and-Multi-Raft-01-01.png)
------------------------------------------------------------
First, let's synchronize a few terms in our Raft consensus algorithm:
- Leader: The manager in the cluster, all client traffic passes through the leader. Normally, there is only one leader, who periodically sends a heartbeat to the follower to maintain control. When I find out that I'm not a leader, I'll become a follower.
- Follower: The manager in the cluster will only respond to commands from other servers. It will become a candidate after not getting a leader response for a long time.
- Candidate: Candidates of the cluster will start a vote to try to be elected leader.

In the previous lesson, we learned that TiKV uses the Raft consensus algorithm to achieve strong consistency of data in a distributed environment. TiDB databases can only be written through the leader, who will copy the write instructions to followers in the form of logs. When most nodes of the cluster receive this log, we This log is considered committed and can be applied to the Data Persistent Storage Engine (State Machine).

TiDB provides support for three replica by default, and these three replica form a Raft Group. Because a Raft Group processes a limited amount of data, we will split the data into multiple Raft Groups, which we call Multi Raft. The way to split is by range, that is, we will sort the keys of the data in byte order, that is, an infinite key - value map data structure, and then split it into a segment (continuous) key range, each key range is treated as a region.

No gap is allowed between two adjacent regions, that is, the end key of the previous region is the start key Region the latter region. The range of the region uses the mode [start, end) that is open before and after. For the key start, it belongs to this region, but for the end, it actually belongs to the next region.

TiKV Region will have a maximum size limit, and when this threshold is exceeded, they will be split into two Region, such as [a, c) -> [a, b) + [b, c). Of course, if there is no data in the Region, or there is only very little data, it will also be merged with the neighboring Region to become A larger region, such as [a, b) + [b, c) -> [a, c).

As mentioned above, multiple Raft Groups formed by multiple Region are called Multi Raft.
Next, we will highlight a few important features of the Raft consensus algorithm for TiKV:
- Log replication
- Leader elect