Mongodb Concurrent connection

144 views
Skip to first unread message

sath...@amberconnect.com

unread,
Jul 8, 2017, 8:25:31 PM7/8/17
to mongodb-user
We using mongodb 3.4.5 version ...
We would like to use more concurrent connection .... available connection showing 8lakhs and more connections able to create ..
but the connection establishing is 100 by 100 ..
for eg: if we creating 20,000 connection via pymongo it is creating 100 by 100 and reaching 20,000 instead of creating 20,000 connection immediately ...
kindly advise on this case ..

Kevin Adistambha

unread,
Jul 17, 2017, 2:03:12 AM7/17/17
to mongodb-user

Hi

if we creating 20,000 connection via pymongo it is creating 100 by 100 and reaching 20,000

How did you create the 20,000 connections? I assumed you call pymongo.MongoClient() 200 times. The 100 connections limit is the default pymongo connection pool size. You can set this number higher or lower as required, but I would encourage you to check out How does connection pooling work in PyMongo to understand more about how connection pooling works, and set the maxPoolSize and minPoolSize parameters to suit your use case.

As detailed in the page How do I calculate how much RAM I need for my application, each connection requires ~1MB of RAM in the server. Opening 20,000 connections would then requires 20GB of RAM in the server, only for holding open connections. If the application does not require all 20,000 connections to be active at the same time, this would decrease the amount of memory available to MongoDB, which could be detrimental to the database's performance. In a typical application, proper usage and setup of connection pooling could allow for high concurrency while optimizing the server’s memory requirements.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages