-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4
-
Component/s: None
-
Labels:
-
Environment:node-mongodb-native 1.4.0, mongos 2.4.10, mongodb 2.4.8/2.4.9, 4 replica sets (not sharded) with set members spread across AWS availability zones, MMS
-
Empty show more show less
The problem:
- We've been using secondaryPreferred and readPreferenceTags to spread load to secondaries and save bandwidth costs by keeping reads in the same data center.
- Switching from replica set connection to mongos changed our reads to master, increasing the load on masters and costing us bandwidth.
- We've temporarily worked around the load by setting readPreference to 'nearest' on individual queries, but this is still costing us bandwidth between data centers, because we're not getting tagged reads.
Here's how the old setup is invoked:
MongoClient.connect( "mongodb://username:password@d1.r2.mongo,d2.r2.mongo,d3.r2.mongo/db_name?w=1&replicaSet=rs2&readPreference=secondaryPreferred&maxPoolSize=1&connectTimeoutMS=15000&readPreferenceTags=availabilityZone%3Aus-east-1d&readPreferenceTags=" , { server: { auto_reconnect: true, poolSize: 1 } } , function(err, db) { ... });
Here's how we're connecting to a local mongos:
MongoClient.connect( "mongodb://127.0.0.1/db_name?w=1&readPreference=nearest&readPreferenceTags=availabilityZone%3Aus-east-1d&readPreferenceTags=" , { server: { auto_reconnect: true, poolSize: 1 } } , function(err, db) { ... });
Can we set readPreference at the MongoClient.connect() level? What about readPreferenceTags? I noticed the bugfix in 1.4 related to this. Does it only work with the 2.6 mongos?
Thanks!
Ryan