Why do Raft clusters usually have three or five nodes? What would you gain or lose with four or six?
Sketch your own answer first, then compare it with the one below.
A strong answer
A cluster of n nodes needs a majority of floor(n/2) + 1 to make progress. Three nodes need 2 and tolerate 1 failure. Four nodes need 3 and still tolerate only 1. Five need 3 and tolerate 2. Six need 4 and tolerate 2.
So going from three to four adds a machine and gains nothing in fault tolerance, while every commit now has to reach three nodes instead of two. The same holds from five to six. Even sizes pay for hardware and latency without buying a failure.
Even sizes have a further drawback: a clean split. A four-node cluster cut into two and two has no side with a majority, so the whole cluster stops. A five-node cluster cut two and three always has one live side.
Three is common for small deployments, and five is used when the cluster must survive one node being down for maintenance while another fails. Beyond five or seven, each commit waits on more replicas and the leader sends more messages, so larger groups buy tolerance at a steady cost in latency.
Sources
- Diego Ongaro, John Ousterhout (2014). In Search of an Understandable Consensus Algorithm.