How to select a leader in RAFT consensus protocol Suppose a network of 5 nodes uses RAFT consensus protocol. Each nodes maintains a transactions log which consists of a list of the log entries. Each log entry again consists of index and term. All of them are marked themselves as leader candidate and send the request Vote (term, index). The current log entries (i.e. list of term and index values) of all the leader candidate nodes as follows - 



Then who will be the leader ?
In the RAFT algorithm if a candidate who wants to become a leader in the network then his proposed "term value" will be checked at the beginning.
1) If it's less than the present "term value" then he will not be selected as a leader.
2) If it's more than the current "term value" then his current "index value" will be checked.
a) If his index value is less than the current index value then he won't be selected.
b) If his index value is more than current index value then he will be selected as leader.

In this case "Candidate 4" will be leader as in every round his term value is not lesser than current term value and his index is updated to current node.