AlgoViz

Consensus and replicated logs

medium 4 min

Consensus allows a replica group to agree on an ordered history across leader changes.

Video lesson · Chapter 1 of 5

Deployment eleven is installed

0:00 / 3:50

When does the third copy make a log entry safe?

1:13Reel

Theory

Read or listen first. About 1 min.

What it is

A leader can have a new entry in its own log before that entry is committed. For an entry from its current term, the leader tracks how many voters have durably replicated it.

A five-voter Raft log at index 12

VoterABCDEIndex 121212———Acknowledged by A and B2 of 5 · entry still pending
The leader’s current-term entry is present on A and B. Two of five voters cannot establish a majority.

Why it exists

In a five-voter group any two majorities overlap. Together with Raft’s election and log rules, that overlap protects committed history through leadership changes.

Words to know

Commit index
The highest log position a server knows is committed.

How it works

Step through the idea, or press Play.

Step 1 of 3

Split five voters. Three can still communicate; two are isolated.

Understand it

Worked example

Consensus and replicated logs in practice

With five voters, three can form a majority. A split into three and two can leave the three-node side able to progress. The two-node side cannot independently commit conflicting entries.

Related case

What can a disconnected region promise?

Three regions replicate a directory of active deployment versions. A network split leaves one region isolated. Engineers need to know which reads and writes may still succeed.

Three regional deployment boards
A rollout across three regionsRegion Arevision 11Region Brevision 11Region Crevision 11Three voters have revision 11

Fast reads can include a revision and age.

Sources