Predict the output
How many node failures can each cluster size tolerate while keeping a majority?
for n in (3, 4, 5):
print(n, (n - 1) // 2)Hint 1 of 1
Majority of n is n // 2 + 1.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A 3 1, 4 1, 5 2
Correct. A majority of 4 is 3, so a 4-node cluster still only survives one failure.
Raft commits only with a majority, floor(n/2) + 1, so it survives n minus that many failures. A 4-node cluster needs 3 votes and tolerates one failure, the same as 3 nodes.
Why not the others?
- B
3 1,4 2,5 2. Losing 2 of 4 leaves 2, which isn't a majority of 4. - C
3 2,4 2,5 3. Those leave a minority behind. - D
3 1,4 1,5 1. 5 nodes keep a majority (3) after 2 failures.