Consensus and Raft, explained simply
Consensus is how a group of machines agrees on one value, or one sequence of changes, even when some crash or can't be reached. It sits under leader election, locks, stores like etcd and ZooKeeper, and most distributed databases' metadata. You won't be asked to code it. You'll be asked what it guarantees, what it costs, and why clusters have 3 or 5 nodes.
A committee keeping minutes
A club committee of five keeps its minutes in five notebooks, one each. The chair proposes each new line and reads it out; a line counts once at least three members have copied it into their notebooks. If the chair stops turning up, any member can call an election. Everyone votes once per election, and never for someone whose notebook is missing lines they have themselves. Each election gets a new number, and a former chair who walks back in and hears a higher number sits down.
- the minutes → a replicated log: every change, in order
- the chair → the leader, the only node that adds entries
- the other members and their notebooks → the followers, each with its own copy of the log
- three of five notebooks → a majority: the entry is committed
- the election number → the term
- "not missing lines I have" → the voting rule that keeps committed entries safe