We have a replicaset with two servers in the connection string, with secondaryPreferred. In case of downtime of the secondary server we want MongoDB to connect to the primary automatically. This works well in "normal" downtime cases, however it seems the MongoClient always connects to both of the replicaset members. Even if it connects to the first secondary first it also connects to the primary, which is only needed for update queries.
The problem is when the primary has a connection timeout: the website tries to connect for 60 seconds, before it continues to serve from the secondary. Also it seems to be useless overhead.
I did not test it, but I think the thing is the same with primaryPreferred.
Is it possible to change this behavior?
Configuration:
PHP MongoClient 1.5.7
Connection string: mongodb://192.168.1.24:27017,192.168.1.25:27017'
Parameters:
readPreference: secondaryPreferred
replicaSet: dnm
Servers: primary, secondary, arbiter