0

Could someone help validate our setup

Setting up a 4 node MongoDB cluster 1 primary (write ) , 3 secondaries (read) if primary goes down, 3 secondaries can break tie and elect a secondary to primary

  1. Will this setup work?
  2. is an arbiter required in such a scenario?

Once I set it up this way at the outset, then as load increases all I need to do is keep adding nodes in pairs to the cluster. (Adding nodes in pairs will help us keep up with performance and reduce the frequency of cluster changes, also we are more read heavy than writes, at some point we will have to consider scaling out writes as well )

Help is very much appreciated.

thanks.

3
  • I've answered below, and voted to have this moved to the DBA Stack Exchange site (dba.stackexchange.com). StackOverflow is for programming related questions rather than database administration questions, so you should ask this type of question there in the future. For this question, you can either migrate it, or it will be automatically moved once there are enough votes to move it. Oct 3, 2014 at 13:03
  • I am trying to find how I could move this to dba.
    – restack
    Oct 3, 2014 at 14:53
  • Can't figure out how to move to DBA.Stack
    – restack
    Oct 3, 2014 at 15:52

1 Answer 1

0

Yes, an arbiter is required, otherwise if 2 nodes go down or are otherwise unavailable, you will not have a primary - MongoDB requires a strict majority (>50%) of votes to elect a primary, and in your case that majority number is 3 out of 4 (two out of 4 is not greater than 50%). That number will still be 3 if you add an arbiter, but you will be able to have a primary with 2 data bearing nodes down.

As for why, consider the following possibility:

2 nodes are isolated from the other 2 - they are still up, functional, but cannot talk to each other. There are now 2 votes on either side of this "split" and no way to break the tie - each side is just as valid in terms of voting for a primary, and without the strict majority rule you end up with 2 primaries and no way to resolve writes once the split resolves itself. Add an arbiter to either side of the split and you have no such ambiguity.

This type of scenario has a number of permutations when the number of votes are even which I won't go into here. Suffice it to say that the best practice when running a replica set is to always have an odd number of votes and hence avoid these situations.

2
  • It appears MongoDB always requires an arbiter (atleast as a best practice) Appreciate your response.
    – restack
    Oct 3, 2014 at 13:07
  • 1
    It does not if you have an odd number of data bearing nodes (3, 5, 7 etc.). It is required if you have an even number of data bearing nodes in order to break ties. Well, you can manipulate votes also, but the above is the general case Oct 3, 2014 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.