Reputation: 591
I have a MongoDB replica set and want to know if it is possible to distribute queries evenly between the members of the set to increase the performance. If it is possible please let me know how to achieve this. I'm using the 10gen Java-driver 2.12.1.
Thank for your help.
Upvotes: 3
Views: 319
Reputation: 9507
It is possible, but you would need to implement the query distribution at the driver level using a ReadPreference.
You should carefully consider the fact that secondary reads may return stale data. You should also carefully consider whether or not the added complexity of implementing the query distribution and tolerating stale data are warranted. I would suggest that you start by doing some performance tests using the primary
(default) ReadPreference.
It is also worth pointing out that what you are trying to accomplish (read scaling) can be better accomplished using sharding, without the need for additional client logic and use of a secondary ReadPreference.
Upvotes: 4