1

I have a two-machine MongoDB replica set. The primary is private (used internally) and it is critical that it stays running smoothly. The secondary is our public copy of the primary which is non-voting. It does not matter much if the secondary crashes (e.g. if there is too much read load on the machine).

I want the secondary to take all the read load that comes from the public internet. I have enabled reads from the secondary with rs.slaveOk(). However, someone can still set the read preference to primary to read from the primary.

How can I prevent the secondary from forwarding reads to the primary, thereby risking to overload the primary?

Community
  • 1
  • 1
Randomblue
  • 112,777
  • 145
  • 353
  • 547
  • You cannot really since MongoDB drivers will connect to that secondary and understand the primary by calling `isMaster()` so this is one of these times you have to ensure people who code applicatons do not force primary – Sammaye Nov 04 '16 at 15:37
  • If, for some reason people are using the console, you could make a .mongorc and make the `readPref` function do nothing – Sammaye Nov 04 '16 at 15:38

0 Answers0