我已经使用spring实现了一个应用程序,在调查mongodb日志时,我发现连接只是在一周内没有释放
Tue Jul 23 11:26:04 [initandlisten] connection accepted from 127.0.0.1:38772 #92 (83 connections now open)
Tue Jul 23 11:27:59 [initandlisten] connection accepted from 127.0.0.1:38789 #93 (84 connections now open)
Tue Jul 23 11:28:44 [initandlisten] connection accepted from 127.0.0.1:38794 #94 (85 connections now open)
Tue Jul 23 11:29:08 [initandlisten] connection accepted from 127.0.0.1:38802 #95 (86 connections now open)
Wed Jul 24 05:46:09 [initandlisten] connection accepted from 127.0.0.1:39045 #96 (87 connections now open)
Wed Jul 24 05:46:32 [initandlisten] connection accepted from 127.0.0.1:39048 #97 (88 connections now open)
Wed Jul 24 05:47:14 [initandlisten] connection accepted from 127.0.0.1:39054 #98 (89 connections now open)
Wed Jul 24 05:48:44 [initandlisten] connection accepted from 127.0.0.1:39057 #99 (90 connections now open)
Wed Jul 24 11:41:50 [initandlisten] connection accepted from 127.0.0.1:39146 #100 (91 connections now open)
我不希望mongodb达到maxConnection限制并停留一天,我怎么能处理这种情况?
mongodb版本:2.2
最好的问候
谢谢
答案 0 :(得分:0)
如果要关闭空闲连接,请查看MongoDB connection reference和maxIdleTimeMs选项。
话虽这么说,达到最大连接数并不意味着应用程序会卡住,它只会限制应用程序可以同时使用的连接数。