I'm using the native driver in PHP to connect to a mongo DB.
I don't understand the concept of connection pooling: is this like a 'pool' of connections, and when a user opens the website, a connection is pulled from this pool and used?
But what if you have multiple pages with some code that uses a mongoDB? Will the system pull a new connection from the pool every time the user changes the page?
In general: how can I manage this 'connection pool' (or is it managed automatically) when there are a lot of simultaneous connections?
I don't understand the concept of connection pooling: is this like a 'pool' of connections, and when a user opens the website, a connection is pulled from this pool and used?
Yes, that's exactly what it is.
But what if you have multiple pages with some code that uses a mongoDB? Will the system pull a new connection from the pool every time the user changes the page?
Yes. The connection is taken from the pool when required (a user loads a page), and then returned to the pool when the script ends. It is persistent by default (set via the mongo.allow_persistent
php.ini setting) and automatically handled by the driver.
In general: how can I manage this 'connection pool' (or is it managed automatically) when there are a lot of simultaneous connections?
Connection pools are mostly managed automatically. You have some level of control using the MongoPool class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With