Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
2.3
-
None
-
Minor Change
Description
The API should have a way to configure a minimum response time a slave must have before it can be used for queries (using slaveOK).
I have 5 mongod instances, 2 capable of being primary. 3 as read only slaves (priority 0). One of the 3 read only slaves is performing poorly (a switch is dying, latency is spiking > 900ms). Because the current algorithm has an element of randomness in it, some of the requests are being served by this poorly performing server. This is due to ReplicaSetStatus.getASecondary() calling "if ( diff > 15 || ( ( badBeforeBest - mybad ) / ( _all.size() - 1 ) ) > _random.nextDouble() )".
The driver should support a minimum cut off. getASecondary() should enforce a latency ceiling in choosing random slaves. I've submitted a patch that does this, using a default of 200ms as a cut off, configurable in MongoOptions.