Am working with node.js and mongodb and am quite new to the concepts, when tried to insert a huge data on to the mongodb the connection made with the mongodb on the local machine lost and the insertion stops and i found that the connection is made to insert the data to the db is 5 as it is the default connection, can please some one help me to increase the default connection from 5 or any suggestions to insert a huge data on to the mongodb using node.js. Am using mongoclient to establish the connection to the db.
Asked
Active
Viewed 264 times
1 Answers
0
The default pool size for connecting mongodb is 5 which is set as a default value. To increase the pool size use
var MongoClient = require('mongodb').MongoClient;
var mongoServer = require('mongodb').Server;
var serverOptions = {
'auto_reconnect': true,
'poolSize': 5
};
var mongoClient = new MongoClient(new mongoServer('localhost', 27017, serverOptions));
//Where in the pool size can be increased by increasing the poolSize value //eg: 'poolSize':100 will increase the connections into 100 provided the available connections are more.

sabari
- 91
- 2
- 14