自动重新连接时MongoDB开放连接太多

时间:2015-07-27 19:38:07

标签: node.js mongodb

我正在使用nodejs + mongodb(mongodb-native)创建api服务器。我的应用程序只打开一次连接并重复使用。

当我的应用程序连接到数据库(mongod日志)

2015-07-28T02:28:06.485+0700 I NETWORK  [conn3] end connection 127.0.0.1:62621 (0 connections now open)
2015-07-28T02:28:06.486+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:62622 #4 (1 connection now open)
2015-07-28T02:28:06.488+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:62623 #5 (2 connections now open)
2015-07-28T02:28:06.488+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:62624 #6 (3 connections now open)
2015-07-28T02:28:06.491+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:62625 #7 (4 connections now open)
2015-07-28T02:28:06.491+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:62626 #8 (5 connections now open)

“5个连接现在打开”确定它是正确的。

然后我尝试关闭mongod 10秒然后再次启动mongod。

2015-07-28T02:30:39.533+0700 I NETWORK  [conn22] end connection 127.0.0.1:63002 (21 connections now open)
2015-07-28T02:30:39.534+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:63003 #23 (22 connections now open)
2015-07-28T02:30:39.538+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:63004 #24 (23 connections now open)
2015-07-28T02:30:39.538+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:63005 #25 (24 connections now open)
2015-07-28T02:30:39.538+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:63006 #26 (25 connections now open)
2015-07-28T02:30:39.539+0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:63007 #27 (26 connections now open)

“26个连接现在打开”有什么问题?

这是我的连接选项

options: {
        server: {
            poolSize: 5,
            auto_reconnect: true,
            reconnectTries: -1,
            reconnectInterval: 1000,
        }
    }

这是问题还是没问题?如何解决?

0 个答案:

没有答案