Search code examples
mongodbloadshardingmongodb-java

Adding a new secondary in MongoDB to Distribute Load


I have two shards on three machines (using mongodb 1.8.2):

nodeI   including:   shard1(primary) and shard2(primary)
nodeII  including:   shard1(secondary) and shard2(secondary)
nodeIII including:   shard1(arbiter) and shard2 (arbiter) 

NodeII load is getting very high(CPU and IO), and NodeI is high as well, but a little better than nodeII.

In my java client I designated code to only query NodeII, while NodeI is just used for writing.

I am planning to convert nodeIII from arbiter to secondary to share the read load on NodeII.

Do you think this is a good idea and if I do this, what should I consider, or do you have other suggestions to lower the load?


Solution

  • As long as the arbiter hardware has similar specifications to your secondary, the approach you are suggesting seems reasonable as it will distribute the secondary reads. Usually arbiters have very low hardware specs or are on shared hardware, but I am assuming that this is not the case in your configuration.

    If you have an odd number of servers in the replica set you will no longer need an arbiter.

    You may want to look into Read Preference here, in particular you might be interested in specifying tag sets to select a secondary.