Because there have been a large number of articles on the Internet that have introduced the raft algorithm in detail, this part will only briefly explain the basic principles and procedures of the algorithm. The raft algorithm contains three roles, namely: follower, candidate and leader. A node in the cluster can only be in one of these three states at a certain time, and these three roles can be changed with time and conditions.
The raft algorithm mainly has two processes: one process is leader election, and the other process is log replication, in which the log replication process will be divided into two stages: logging and submitting data. The largest fault-tolerant node supported by the raft algorithm is (N-1)/2, where N is the total number of nodes in the cluster.
There is an animation abroad that introduces the raft algorithm very thoroughly. The link address is: http://thesecretlivesofdata.com/raft/. This animation mainly contains three parts. The first part introduces the simple version of the leader election and log copy process, the second part introduces the detailed version of the leader election and log copy process, and the third part introduces if you encounter Network partition (split brain), how the raft algorithm restores network consistency. Interested friends can combine this animation to better understand the raft algorithm.