Mongodb – Set or limit number of connections a single pymongo client will open

mongodbpython

Is there a way to set or limit the number of connections to Mongo a single pymongo client instance will open? I don't want to modify Mongo config to do this, because I don't want to affect other applications.

Best Answer

Use the following parameter to set the number of maximum connections from your pymongo app.

client = MongoClient(host, port, maxPoolSize=10)

Here is documentation with more details.