Commitment and the Commit Index
What you'll learn: How Raft determines when a log entry is safe to apply and how the commit index tracks this progress.
What Does "Committed" Mean?
In Raft, a log entry is considered committed when it has been safely replicated to a majority of servers. Once committed, the entry is durable and guaranteed never to be lost—even if the leader crashes. The leader can then safely apply this entry to its state machine and inform followers to do the same.
Think of it like a group vote: once more than half the committee has written down their vote, the decision is final and can be announced publicly.
The Commit Index
The commit index is a variable each server maintains that tracks the highest log entry known to be committed. The leader advances its commit index when it confirms an entry has been replicated to a majority. Followers learn about committed entries through the AppendEntries RPC—the leader includes its current commit index in every message.
When a follower receives an AppendEntries with a higher commit index, it updates its own and applies all entries between its old commit index and the new one to its state machine.
How It Works
- Leader appends a new entry to its log
- Leader sends
AppendEntriesto all followers - Followers acknowledge successful replication
- Once the leader receives acknowledgments from a majority (including itself), it advances its commit index
- On the next
AppendEntries(even heartbeats), the leader shares the new commit index - Followers apply committed entries to their state machines
Key Takeaway: The commit index is Raft's safety mechanism—it ensures entries are only applied after majority replication, making them durable and permanent across the cluster.