Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb connection pooling

I am using Java driver to access mongodb. I assume the db connection pooling is internally handled by the driver.But my connection count getting increased every time I access db.

This is my serverStatus log.

"connections" : {
            "current" : 276,
            "available" : 543
    }

Do I need to explicitly close mongo connections? how should I manage connection pooling in java?

like image 693
Deepan Avatar asked Jan 23 '12 06:01

Deepan


People also ask

What is connection pooling in MongoDB?

Definition. A connection pool is a cache of open, ready-to-use database connections maintained by the driver. Your application can seamlessly get connections from the pool, perform operations, and return connections back to the pool. Connection pools are thread-safe.

How many connections can MongoDB handle?

MongoDB configuration Even MongoDB itself has an option to limit the maximum number of incoming connections. It defaults to 64k.

How does Mongoose connection pool work?

You can specify an amount of open connections to maintain to your database (let's say 10). Each time your Node JS code makes a query, if possible, it'll use one of the already-open 10 connections to make this request -- this way you can avoid the overhead of opening a new database connection for each query.

What is MongoDB Poolsize?

Most MongoDB drivers support a parameter that sets the max number of connections (pool size) available to your application. The connection pool size can be thought of as the max number of concurrent requests that your driver can service.


1 Answers

You can set max pool size mongodb://***/?maxPoolSize=5 for detail Review this documentation https://docs.mongodb.com/manual/reference/connection-string/

like image 57
Karthik Avatar answered Oct 03 '22 03:10

Karthik