I ́m testing around with MongoDB and NodeJS. I ́m stuck with the problem that I can create max 4899 connections to MongoDB. I ́ve set the poolSize in the NodeJS Mongo driver to 40000. Also I ́ve set the needed ulimits of the mongo server.
Does anyone have an idea why the mongo server refuses new connections as soon as 4899 are reached? The problem is definitely on th DB server side and not on client side.
I ́m using the newest versions of all components (nodeJS V8, Mongo, Node mongo native driver)
limits configuration:
/etc/sysctl.conf
net.ipv4.ip_local_port_range = 1024 65000
/etc/security/limits.conf
mongodb hard nofile 1048576
mongodb soft nofile 1048576
mongodb soft nproc 1048576
mongodb hard nproc 1048576
mongodb hard stack 16384
mongodb soft stack 16384
mongodb hard memlock unlimited
mongodb soft memlock unlimited
/lib/systemd/system/mongodb.service
# (file size)
LimitFSIZE=infinity
# (cpu time)
LimitCPU=infinity
# (virtual memory size)
LimitAS=infinity
# (open files)
LimitNOFILE=500000
# (processes/threads)
LimitNPROC=500000
mongo serverstats:
db.serverStatus().connections
{
"current" : 4899,
"available" : 395101,
"totalCreated" : NumberLong(5279)
}
-
Possible duplicate of MongoDB high rps running into limits?Marcos Zolnowski– Marcos Zolnowski2017年10月20日 03:24:58 +00:00Commented Oct 20, 2017 at 3:24
-
Yes, the problem it´s self is a duplicate. But I did some more testing and could exclude some possible reasons. Due to that I´ve also changed the question which is now much more specific. Sorry, I´ve deleted the previous question now.teldri– teldri2017年10月20日 07:17:38 +00:00Commented Oct 20, 2017 at 7:17
1 Answer 1
Finally found the solution by myself:
in the systemd service configuration file /lib/systemd/system/mongodb.service set the following values to override the systemd tasklimit:
# (disable systemd tracking of number of tasks)
TasksAccounting=false
# (disable systemd tasklimit) possible values: infinity, a absolute number, or percentage of system wide limit
TasksMax=infinity
-
Teldri, you can also mark your answer as the accepted answer to take full credit for solving the issue :)LowlyDBA - John M– LowlyDBA - John M2017年10月20日 14:15:27 +00:00Commented Oct 20, 2017 at 14:15