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