Hi Megha, Scott,
To be clear: the number of nodes in a replica set does not fluctuate unless you change the configuration (i.e. adding or removing members). A 5 node replica set with 2 nodes down is still a 5 node replica set.
Although "always have an odd number of voting members" is a helpful general guideline, some things to keep in mind are:
- Voting works on a quorum basis, where a strict majority of voting nodes must be available in order to elect or maintain a primary
- A strict majority requires more than half of the voting nodes successfully communicating with each other (i.e. at least n/2 + 1, where n is the number of voting nodes)
- Even number of voting nodes in a replica set are strongly discouraged if you want high availability
Why are even numbers of voting nodes discouraged?
- The strict majority of a 2 node replica set is 2 (no automatic failover possible if either node is down for any reason)
- In the event of network problems, it's possible to have a tied vote (for example, with a replica set equally split across two data centres)
Regards,
Stephen