Learn
Lesson · Replication and Consistency · Majorities and leaders

Majorities and Fault Tolerance

A majority of n is ⌊n/2⌋ + 1, and any two majorities intersect, which is why consensus is built on them. The failures tolerated are f = ⌊(n − 1)/2⌋, so 2f + 1 is the only cluster size worth buying: four nodes tolerate one failure exactly as three do, while needing three of four up instead of two of three. With nodes up 99% of the time that makes four nodes strictly less available than three — 99.940797% against 99.9702%.

majority of n = ⌊n/2⌋ + 1 any two majorities share a node f = ⌊(n − 1)/2⌋ so the useful sizes are n = 2f + 1 n = 3 majority 2 f = 1 A = 99.9702% n = 4 majority 3 f = 1 A = 99.940797% worse, for one more node n = 5 majority 3 f = 2 A = 99.99901494% each node up 99/100, failures assumed independent
Two integers and a binomial tail

Core ideas

What this lesson establishes

The intersection property, the integer that follows from it, and the availability that follows from the integer.

1

Any two majorities intersect, which is why consensus uses them

Two subsets of n each larger than n/2 cannot be disjoint — it is the overlap theorem with R = W = ⌊n/2⌋ + 1. That is what stops two leaders being elected in the same term and two conflicting decisions being committed: any two decisions share a node, and a node does not vote both ways.

2

A majority survives exactly f = ⌊(n − 1)/2⌋ failures

The cluster keeps working while a majority is still up, so it tolerates n − (⌊n/2⌋ + 1) failures, which is ⌊(n − 1)/2⌋. At n = 3 that is 1; at n = 4 it is also 1; at n = 5 it is 2. f only moves on the odd sizes, and n = 2f + 1 is the cheapest cluster tolerating f.

3

An even n raises the quorum and not the tolerance

Going from three nodes to four takes the majority from 2 to 3 while f stays at 1. You now need three specific machines up instead of two, out of a pool with one more thing in it that can break. With independent 99% nodes that is a net loss: 99.940797% against 99.9702%, and the fourth machine has been bought to make the cluster worse.

The material

Majorities, the integer f, and the availability that follows

Why consensus is built on majorities, what an even cluster size actually buys, and the binomial tail that prices both.

Definition · Majority, and fault tolerance

A majority of n nodes is any subset of size ⌊n/2⌋ + 1. A cluster that requires a majority to make progress tolerates f = ⌊(n − 1)/2⌋ failures, and the relation is usually written n = 2f + 1: to tolerate f, buy 2f + 1 nodes.

The intersection property is the reason for all of it. Two majorities of the same n must share a node, by the same pigeonhole argument that “Quorums Overlap” proved, so a node that has voted for one decision can refuse a conflicting one. Nothing else about a majority is special — it is simply the smallest quorum that overlaps itself.

each node up with probability 99/100, failures independent A = P(at least the majority are up), a k-of-n binomial tail n majority f A 1 1 0 99% 2 2 0 98.01% 3 2 1 99.9702% 4 3 1 99.940797% 5 3 2 99.99901494% 6 4 2 99.998044641% 7 4 3 99.99996583302% f rises only on the odd sizes, and A falls on every even one

Read down the f column and the design rule falls out: 3, 5, 7. The even sizes are transitional — they carry the cost of the next size up and the tolerance of the one below. That is why production clusters are almost always odd, and why the advice is repeated so often that its reason gets lost.

Why the fourth node makes it worse

n = 3, majority 2 A = C(3,2)(99/100)²(1/100) + (99/100)³ = 3(9801/10 000)(1/100) + 970 299/1 000 000 = 29 403/1 000 000 + 970 299/1 000 000 = 999 702/1 000 000 = 99.9702% n = 4, majority 3 A = C(4,3)(99/100)³(1/100) + (99/100)⁴ = 4(970 299/1 000 000)(1/100) + 96 059 601/100 000 000 = 3 881 196/100 000 000 + 96 059 601/100 000 000 = 99 940 797/100 000 000 = 99.940797% one more node, the same f, and 0.029403 points LESS availability

The arithmetic is not a curiosity, it is the direct consequence of needing three specific things to work instead of two. Availability of a k-of-n system falls as k rises and rises as n does, and the even step raises k by one while raising n by one — and at 99% per node the first effect wins.

Example · Where the next real step is

From three nodes, the upgrade is five, not four. Five tolerates two failures instead of one and is available 99.99901494% of the time against 99.9702% — a factor of about thirty in the downtime, for two more machines. Four tolerates one failure and is available 99.940797%, which is worse than the three it replaced. If the budget allows one more node and not two, the right answer is to keep three and spend the money on making a node's own availability better, because that is the quantity every figure in this table is a function of.

Every number here assumes failures are independent, and Availability and Failure's “Correlated Failure” exists to say how badly that can go. Three nodes in one rack share a switch, a power feed and an operator; the majority arithmetic is then describing a cluster that does not exist and the real availability is closer to one node's. Spreading the 2f + 1 across failure domains is what makes the independence assumption approximately true, and it is the whole reason to care where the nodes are.

Interactive

Majorities and fault tolerance

f = floor((n − 1)/2), and the availability of the quorum that follows

2f + 1 tolerates fso a fourth node tolerates what three did, and is available less often
odd sizes, which earn their nodeeven sizes, which do notthe majority's availability

Method

Sizing a cluster that needs a majority

Start from the failures you intend to survive, not from the number of machines you happen to have.

1

Decide f first, then take n = 2f + 1

“How many failures must this survive” is a product question with an answer; “how many nodes should we run” is not. One failure means three nodes, two means five, three means seven, and nothing in between is worth buying.

2

Compute the majority ⌊n/2⌋ + 1 and check it against f

n − majority must equal the f you chose. Doing this explicitly is what catches an even n: at n = 4 the majority is 3 and n − 3 = 1, which is the tolerance you would have had for one machine less.

3

Compute the availability as a k-of-n tail at your node availability

A = Σ C(n,k) p^k (1 − p)^(n−k) from k = majority to n. Do it for your n and for n − 1 and n + 1, so that the shape of the table is in front of you rather than remembered.

4

State the independence assumption and where it fails

Name the failure domains the nodes are spread across. If two of three share a rack, the binomial tail is optimistic and the number to report is much closer to that rack's availability than to 99.9702%.

Tolerance, majorities and availability

Score 0 / 0

Three nodes, then four

A three-node consensus cluster is running and a fourth machine has become available. The proposal is to add it, on the grounds that four is more than three. Both halves of the question — tolerance and availability — have exact answers.

each node up 99/100, independent n = 3 majority = ⌊3/2⌋ + 1 = 2 f = 3 − 2 = 1 A = C(3,2)(99/100)²(1/100) + (99/100)³ = 29 403/1 000 000 + 970 299/1 000 000 = 999 702/1 000 000 = 99.9702% downtime ≈ 0.0298% of the time n = 4 majority = ⌊4/2⌋ + 1 = 3 f = 4 − 3 = 1 A = C(4,3)(99/100)³(1/100) + (99/100)⁴ = 3 881 196/100 000 000 + 96 059 601/100 000 000 = 99 940 797/100 000 000 = 99.940797% downtime ≈ 0.0592% of the time the fourth node: f unchanged at 1 availability DOWN by 0.029403 points downtime roughly DOUBLED storage and write work up 33% n = 5 majority 3, f = 2, A = 99.99901494%

Four numbers went the wrong way and one stayed still. The fourth node buys no additional tolerance, roughly doubles the expected downtime, adds a third to the storage and write work, and gives the operator one more machine to patch. There is no reading of that table in which it is an improvement.

The five-node row is the honest alternative and it is a large step: two tolerated failures and about a thirtieth of the downtime. Whether it is worth two machines is a real question; whether the four-node cluster is worth one machine is not.

For a faded rehearsal, suppose the nodes are only 95% available each rather than 99%. The supplied first move is that the n = 3 majority availability becomes 3(0.95)²(0.05) + (0.95)³. Compute it, do the same for n = 4 and n = 5, and say whether the even-size penalty is larger or smaller at 95% than it was at 99% — then check both in the lab.

Common mistakes

1
Believing a bigger majority tolerates more failuresThe majority of four is three, which is bigger than the majority of three, and it tolerates exactly the same single failure. Tolerance is n − majority, and the even step adds one to both sides of that subtraction. This is the misconception the lesson exists to break, and it is the reason four- and six-node clusters get built.
2
Sizing a cluster on an even numberEvery even n is dominated: it costs a machine more than n − 1, tolerates the same failures, and is less available. If somebody has a spare machine, it belongs in a different cluster, or as a non-voting replica that serves reads without joining the quorum.
3
Quoting the binomial availability of nodes that are not independent99.9702% is what three nodes give if their failures are unrelated. Three nodes in one rack, on one power feed, patched by one script at one time, fail together often enough that the correct number is closer to the shared component's availability than to the tail. The arithmetic is only as good as the failure domains the nodes are spread across, and “Correlated Failure” on the availability course is the treatment of what goes wrong when they are not.

Check your understanding

✓
Finish when a proposal to add one node to a three-node cluster makes you ask which failure it is meant to survive.

You should be able to compute ⌊n/2⌋ + 1 and f for any n, evaluate the majority's availability as a k-of-n binomial tail, say why every even size is dominated by the odd one below it, and name the independence assumption and the failure domains it needs.

Note: A majority decides who the leader is, but it does not decide how the candidates agree to hold a vote at all. If every node times out at the same instant they all stand, they all split the vote, and the cluster has no leader — for ever, if the timeout is fixed. “Randomised Election Timeouts” computes the probability of a clean first round and the number of rounds it takes, and shows that a fixed timeout gives exactly zero.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.