Mongo database connection with its own internal pooling.Default pool has a maximum of 10 connections per mongodb host.This should be use class as a singleton. This value is controlled by the variable connectionsPerHost within the class com.mongodb.MongoOptions. To adjust the MongoOptions you simply create an instance of MongoOptions and directly set the variables as required.
MongoOptions mongoOptions = new MongoOptions();
mongoOptions.connectionsPerHost = 20;
mongoOptions.threadsAllowedToBlockForConnectionMultiplier = 100;
mongoOptions.maxWaitTime = 1000;
mongoOptions.connectTimeout = 3000;
mongoOptions.socketTimeout = 3000;
mongo = new Mongo(parseServerAddresses("localhost:27017"), mongoOptions);
Check the number of connections in mongo db shell.
>db.serverStatus()
Comments
Post a Comment