Reputation: 3967
While running zookeeper on a 6 node cluster, does anyone know if the quorum is automatically determined to be 4 nodes or 3 nodes?
If the quorum is chosen as N/2, then it would become 3 and can lead to a split brain situation. If the quorum is chosen as (N+1)/2, then it would become 4 and will avoid the split brain situation.
So I am hoping that it is the latter but the documentation does not mention anything of that sort. Does anyone know this for sure?
P.S. I know that odd number of zookeeper nodes is recommended but I am just curious to know what happens for an even number of nodes case.
Upvotes: 5
Views: 4629
Reputation: 2035
Having an even number of nodes doesn't add any advantage when nodes go down/fail. A 6 node cluster can tolerate up to 2 node failures, meaning it needs at least 4 nodes to avoid the split-brain problems or get the majority vote. which can even be achieved with 5 nodes cluster, meaning 5 nodes cluster also can tolerate up to 2 nodes failure.
So, adding one additional node is just an operational cost.
I have answered the same question in my blog.
Please have a look :) Why Zookeeper has odd number of nodes?
Upvotes: 4
Reputation: 126
I know its an old post but replying for the sake of other who might stumble onto this post.
Zookeeper needs a majority nodes to be up and communicating. So in your case it would be 4 out of 6 which is why odd numbers are used. Isn't one of your nodes redundant from a HA point of view? if 3 nodes go down your cluster is down. same with a 5 node cluster.
Upvotes: 1
Reputation: 595
see org.apache.zookeeper.server.quorum.flexible.QuorumMaj.java
public boolean containsQuorum(HashSet<Long> set)
{
return set.size() > n / 2;
}
Upvotes: 5