Raft consensus explanation

Run consensus

What is distributed consensus

Raft Leader election (brief)

Each node in system can be in 3 states:

By default all nodes are followers. If follower doesn't hear from a leader for some time then it becomes candidate and requests votes from other nodes.

Raft Log Replication (brief)

Each change added as an entry in the node log.

Raft Leader election details

election timeout Time that follower wait until becoming the candidate. Randomized between 150ms and 300ms.

Image for a hint

Image for a hint

If 2 nodes becoming candidate at same time split vote may occur (both voted for itself in current term, and have equal votes from other, so no one has MAJORITY !), all will wait next term


If network partitioned:

Client cant write 3 because majorite not written:

Image for a hint

Another client can write:

Image for a hint

After merging the partitioned network, leader B will see higher election term and step down (A and B will rollback uncommitted entries and match leader's log

Tip based on http://thesecretlivesofdata.com/raft/

Raft Paper raft.pdf

Raft site: https://raft.github.io/

Ivan Borshchov profile picture
Jul 27, 2017
by Ivan Borshchov
Did it help you?
Yes !