· Datacenter

Why three hosts is the minimum I would run

Quorum arithmetic, maintenance and failure tolerance for a small cluster, and why two nodes plus a witness is a compromise you should buy knowingly.

Three. If a workload matters enough to cluster, I would not run it on fewer than three hosts. Two hosts with a witness will work, and I will get to when I would accept that, but it is a compromise and you should buy it knowing so.

The arithmetic of quorum

A cluster has to agree on its own state: which hosts are members, who holds which resource, what the current configuration is. Almost every clustering system settles this by majority vote. The etcd documentation gives the rule in one line: for a cluster with n members, quorum is (n/2)+1. Its table of what follows from that is worth memorizing.

  • 1 member: majority 1, tolerates 0 failures
  • 2 members: majority 2, tolerates 0 failures
  • 3 members: majority 2, tolerates 1 failure
  • 4 members: majority 3, tolerates 1 failure
  • 5 members: majority 3, tolerates 2 failures

Two lines in that table surprise people. A two-member cluster tolerates no failures at all, because the majority of two is two. And a fourth member buys nothing over three for fault tolerance. In etcd's words, adding a member to bring the cluster up to an even number "doesn't buy additional fault tolerance."

Fail a host and see whether the cluster still has a majority
Hosts in the cluster

The cluster keeps running. 3 hosts up, and a cluster of 3 needs 2. A cluster this size tolerates 1 failure.

Majority is (n/2)+1, rounded down, as in the etcd table quoted in this post.

The reason for majority voting is the failure a cluster fears most. When two hosts lose contact, neither can tell whether the other has died or the link between them has. If both assume the other is dead and both carry on, you have two copies of the same workload writing to the same data. Requiring a majority means at most one side of any split can keep running.

What a witness does

With two hosts there is no majority to be had after a failure, so two-node designs add a tie-breaker. Corosync, the open source cluster engine, shows both ways of doing it. Its two_node option sets quorum artificially to 1 so that either node can continue alone, which then depends on other mechanisms to stop both continuing at once. The alternative is a quorum device: a small daemon on each node that gets an extra vote from a third-party arbitrator running somewhere else. The corosync-qdevice documentation recommends it for clusters with an even number of nodes and calls it "highly recommended for 2 node clusters."

A witness, then, is a vote. It holds no workloads and no copy of your data. It answers one question, which side continues, and it answers it well provided it sits somewhere that does not fail along with either host. A witness running on one of the two hosts it arbitrates for is decoration.

Why that is a compromise

Count what you have left after one host fails in a cluster of two hosts and a witness. Quorum survives, so the cluster keeps running. Compute is down to one host, so that host must be able to carry everything, which means you could never have used more than half of what you bought. And every piece of data is down to one copy on one machine. You are a single fault away from an outage, and for data, a single fault away from a restore.

Now consider that you enter this state on purpose every time you patch. To update one host you empty it and reboot it. For as long as that takes, a two-node cluster is a one-node cluster with a vote attached. If you patch monthly, you choose to run without redundancy twelve times a year, before counting any unplanned failure.

Three hosts change each of those numbers. With one host out, two remain. Quorum holds without outside help. The workload spreads across two machines, so each of the three could have been running at two-thirds. Replicated data still has a second copy. Storage systems that keep their own replicas make the same argument from their side. Ceph keeps three copies of each object by default, and its documentation warns that setting the copy count to two, or allowing I/O with only one copy active, "risks data loss" and should only be done in emergencies, and then only temporarily. Ceph also recommends at least three monitors, for the same majority reason.

What three does not give you

One caveat, and it matters. Three hosts tolerate one host being out. Maintenance spends that allowance. If a second host fails while the first is being patched, a three-host cluster loses quorum like any other. Surviving a failure during maintenance takes five voting members, per the same table. A fourth host helps with capacity, since losing one of four costs you a quarter of your compute where losing one of three costs a third, but it adds nothing to quorum.

So here is what three buys, stated exactly. You can lose a host, or take one out on purpose, and keep running with a second copy of your data still in place. You cannot do both at the same time.

When I would accept two and a witness

Small remote sites, where the alternative is a single server and the workload can tolerate a short outage. Places where space or power allows two machines and no more. Budgets where the third host is the difference between doing the project and not doing it.

In those cases, be specific about what you bought.

  • The witness goes in a different failure domain, ideally a different site.
  • Someone owns monitoring it, because a dead witness is silent until the day you need its vote.
  • Each host is sized to run everything alone.
  • The people who own the service know that patching day is a day without redundancy.

The same arithmetic applies on the small machines I run at home. Quorum does not care what the hardware cost.

If you are pricing a new cluster and the quote comes back with two hosts and a witness to hit a number, ask for the three-host price before you sign. The difference is usually one server, and it is the server that lets you patch on a weekday.

Views are my own.