2

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 Oct 20 '17 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 Oct 20 '17 at 7:17
2

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 Oct 20 '17 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.