Lesson 1 · Unit 04
Why agreement is hard
Majorities, odd clusters and fencing tokens
What you practise
- Leader election, majorities and why clusters have odd sizes, two leaders at once, fencing tokens, what a consensus algorithm promises
Try a question from this lesson
Pick one
Five nodes must agree on one leader. The network splits them 3 | 2, and each side sees only itself. Which rule guarantees there is never more than one leader?
Correct answer
A leader needs votes from a majority of all 5 nodes
Why
Two groups cannot both hold more than half of five. The side with 3 can elect a leader; the side with 2 can count to 2 and no further, so it elects nobody. Majority voting is the heart of every consensus algorithm.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
What consensus promises
Consensus means getting several nodes to decide on one value, such as who leads or what the next log entry is.
Two promises matter. Safety: no two nodes ever decide differently, whatever fails. Progress: a decision is reached as long as a majority is up and can talk.
Safety is never traded away. When too many nodes are unreachable, the system stops instead of guessing.
Concept
Fencing tokens
Every election hands out a number that only goes up, called a term or epoch. The leader sends its number with every request, as a fencing token.
The storage remembers the highest token it has seen and rejects anything lower. A leader from an older term is fenced off, even if it never learns it was replaced.
term 33: leader A term 34: leader B
B -- write, token 34 --> storage: ok
A -- write, token 33 --> storage:
rejected,
has seen 349 more exercises in the app
- 3× type the answer
- 3× multiple choice
- 1× true or false
- 1× fill the blanks
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.