I'm trying to improve my app's performance , and read that it's good practice to create multiple client connections so that mongodb can process queries in parallel (each client connection's queue being processed synchronously)
I'm using mongoose, and reading the connection docs, I see that you can set poolSize (default is 5). I haven't set the poolsize on my connections, so assuming it should be the default 5
var mongoOptions = {
server: {
poolSize: Number(process.env.MONGO_POOLSIZE) || 5
}
}
mongoose.connect(DATABASE_URL + "?authMechanism=SCRAM-SHA-1", mongoOptions);
Ran db.serverStatus().connections
in my mongo client, and see the below response
{ "current" : 9, "available" : 195, "totalCreated" : NumberLong(2058) }
I know that includes the mongo shell connection, but why is it 9 current connections vs 6? When I disconnect my server it goes down to 1 as expected.
Then if if I do set poolSize to 180 , I still get the 9 connections vs my settings.
Could someone explain
How does mongoose connection pool work?
poolSize
connections for internal use.Why is my poolSize doesn't get applied?
Does having multiple connections mean that my queries would get process in parallel by mongo db ? or does one mongoose connections means one client connection?
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