In below code we can connect MongoDB
var options = {
db: { native_parser: true },
server: { poolSize: 5 },
replset: { rs_name: 'myReplicaSetName' },
user: 'myUserName',
pass: 'myPassword'
}
mongoose.connect(uri, options);
Here poolSize is 5. So that 5 parallel connection can be perform on request.
But I see if we try to create second connect node gives error that I'm trying to create connection which is not closed. So at the same time one connection can do perform for one application.
So what is meaning of poolSize is 5 and how it perform?
I need a solution and a way to increase pool size when my system is scale up.
Thanks in advanced.
Mongoose (or rather the
mongodbdriver it uses) will automatically manage the number of connections to the MongoDB server. You should callmongoose.connect()just once.If you need a larger number of connections, all you have to do is increase the
poolSizeproperty. However, since you're using a replicate set, you should setreplset.poolSizeinstead ofserver.poolSize: