Raft's Log Replication Protocol

Learn how the log replication works in Raft.

A log comprises one or multiple log entries, and each entry holds an executable application-specific command. The basic responsibility of Raft is to maintain a consistent sequential log across all servers. Let’s see how Raft implements this in its algorithm.

Log replication

After a leader is chosen in an election, it handles client requests. These requests contain instructions to be executed by the state machines. The leader adds the instruction to its log as a new entry and sends AppendEntries RPCs to all other servers in parallel to replicate the entry. Once the entry has been replicated safely (after a majority of the followers have successfully replicated it), the leader applies it to its own state machine and provides the result of the execution to the client.

Suppose followers malfunction or operate slowly, or network packets are lost. In that case, the leader will continue to retry AppendEntries RPCs until all followers store all log entries, even after it has already responded to the client.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.