0

PyMongo has a MongoClient for connecting to single nodes, and a MongoReplicaSetClient for connecting to entire replica sets; the latter is able to route reads to secondaries and monitor set health. But what is the difference if I connect to a mongos instead of the replica set nodes? As far as I understand, mongos handles all the routing and monitoring itself.

1 Answer 1

0

MongoClient is for connecting to standalones and mongos, because the driver doesn't have to handle failover in those cases. The mongos handles the routing, etc. when it is connected to replica sets. When connecting to a single replica set, use the MongoReplicaSetClient so the driver will handle autodiscovery of set members, failing over to a new primary, etc. See High Availability and PyMongo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.