I have a Node.js app running in EC2 connecting to MongoDB that is constantly opening and closing connections. When I tail the log file I see an endless stream of:
Sat Feb 2 23:29:06 [initandlisten] connection accepted from X.X.X.X:54291 #700437
Sat Feb 2 23:29:06 [conn700437] end connection X.X.X.X:54291
Sat Feb 2 23:29:06 [initandlisten] connection accepted from X.X.X.X:42206 #700438
Sat Feb 2 23:29:06 [conn700438] end connection X.X.X.X:42206
Sat Feb 2 23:29:06 [initandlisten] connection accepted from X.X.X.X:34255 #700439
Sat Feb 2 23:29:06 [conn700439] end connection X.X.X.X:34255
Sat Feb 2 23:29:07 [initandlisten] connection accepted from X.X.X.X:49641 #700440
Sat Feb 2 23:29:07 [conn700440] end connection X.X.X.X:49641
Sat Feb 2 23:29:08 [initandlisten] connection accepted from X.X.X.X:54293 #700441
The connection is made once during the app startup process like so:
app.configure('production', function() {
mongoose.connect('connstring');
})
app.configure(function database() {
mongoose.connection.on('error', function (err) {
console.log(err);
});
});
I have two questions.
First, is this normal?
Second, why would there not just be a few connections open for the connection pool?
Thanks
Looks like they may have added a fix to your issue in the last mongodb driver release here:
https://github.com/mongodb/node-mongodb-native/blob/master/HISTORY
1.2.11 2013-01-29 - Ping strategy now reuses sockets unless they are closed by the server to avoid overhead
Yes this is normal. The driver sends pings to your nodes to continually monitor the health of your entire cluster, including secondary nodes.