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)
}
asked Oct 19, 2017 at 12:22
2
  • Possible duplicate of MongoDB high rps running into limits? Commented 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. Commented Oct 20, 2017 at 7:17

1 Answer 1

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
answered Oct 20, 2017 at 12:56
1
  • Teldri, you can also mark your answer as the accepted answer to take full credit for solving the issue :) Commented Oct 20, 2017 at 14:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.