Sign in
Log inSign up

MongoDB Replica set : Best practices while reading from secondaries?

Keerthana Srinivasan's photo
Keerthana Srinivasan
·Aug 30, 2016

I'm trying to implement a mongo replica set for one of our DBs. I would like to have some of the dashboard/MIS queries to be run on the secondary so that it does not load the primary.

What are the best practices to implement this? Do you split the application code into 2 so that the reads are redirected to the secondary or is there any other way to do this? I do see the mongo readpreferences - is it better to use that? Any help on this is greatly appreciated.