Course contentsShow
← System Design
Lesson 626 of 1,91917. Consensus AlgorithmsFree lesson

Commitment and the Commit Index

When a log entry is considered committed (replicated on a majority) and how the commit index advances.

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

  1. Leader appends a new entry to its log
  2. Leader sends AppendEntries to all followers
  3. Followers acknowledge successful replication
  4. Once the leader receives acknowledgments from a majority (including itself), it advances its commit index
  5. On the next AppendEntries (even heartbeats), the leader shares the new commit index
  6. 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.