Mongodb – Why mongodb requires arbiter in a 4 members replica set

mongodb

sorry for my trivial question, I read the mongodb documentation but still I do not understand well.
The documentation says that the majority of the members should be considered at the start up configuration of the cluster.
So, if I have 4 members as my replica set, the majority is 3 members.
After the fail over of one member I still have 3 members up and running and they can proceed correctly to perfom the election, why should I need an arbiter for this scenario??
I understand perfectly the need of an arbiter in case of only 2 members, in that case the majority is 2 so if one node goes down the other can not elect himself.

Best Answer

In a replica set configuration with an even number of voting members, an arbiter or additional secondary is strongly recommended (but not required) because:

  • An odd number of voting members avoids potential cases where you could have a tied vote (extending the election process) or fail to elect a primary (if it is possible to have a network split between half your nodes).

  • An odd number of voting members increases fault tolerance. A five member replica set has the same majority as a four member replica set (3 votes required), but the five member replica set allows for 2 members to be unavailable (versus only 1 node of fault tolerance for a four member replica set).

  • As you have noted, if you have a replica set with only two members the strict majority of 2 (n/2+1) does not allow for any fault tolerance. Three members is the minimum recommended replica set size if you want to allow for automatic failover and high availability.

MongoDB 3.0+ will log a warning if you have an even number of voting replica set members, but does not prevent you from using this configuration. The log warning will be similar to:

replSet warning: even number of voting members in replica set config - add an arbiter or set votes to 0 on one of the existing members

As at MongoDB 3.2, replica sets can have a maximum of 7 voting members with up to 50 members in total (see: Replica Set Limits).