Why does the mongodb replica set require an odd number of voting nodes?

The mongodb documentation suggests that the replica set must have an odd number of voting nodes. What is the reason for this?

+7
source share
1 answer

Suppose a replica set has an even number of nodes (for example, 4). Then there is an unfortunate network partition, which splits the set in half (2 + 2). Which section should accept entries? First? Secondly? Both? What should happen during network recovery? These are all difficult questions.

An odd number of nodes completely eliminates questions. A set cannot be broken exactly in half. Thus, most will accept records (more precisely, node should see more than half of the nodes (including itself) that should be selected as primary. Thus, this is 1 out of 1, 2 out of 3, 3 out of 5, 4 out of 7 and so Further).

+7
source

All Articles