0

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.

sabari
  • 91
  • 2
  • 14
  • Seems something similar to http://stackoverflow.com/questions/18814238/closing-mongodb-connection-in-node-js-while-inserting-lot-of-data – Kiran Pagar May 14 '14 at 18:03

1 Answers1

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