mongodb : Increasing max connections in mongodb mongodb : Increasing max connections in mongodb mongodb mongodb

mongodb : Increasing max connections in mongodb


You also need bump up the number of file descriptors and number of file descriptors per process that the Linux kernel allows.

In Linux, this should be configured by editing the file at /proc/sys/fs/file-max or by the sysctl utility.

  • Edit the /etc/sysctl.conf file and add fs.file-max = 50000. This sets the maximum file descriptors that can run as a system-wide limit.
  • Running ulimit -n 50000 sets the user-wide limit for the maximum number of file descriptors open.

Check this link for a more descriptive write-up for editing the limits on a linux machine: http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/


Method 1 If you use systemd (systemctl restart mongod)

sudo mkdir /etc/systemd/system/mongod.service.d/sudo vi /etc/systemd/system/mongod.service.d/limits.conf

then add:

[Service]LimitFSIZE=infinityLimitCPU=infinityLimitAS=infinityLimitMEMLOCK=infinityLimitNOFILE=64000LimitNPROC=64000

Then execute:

systemctl daemon-reloadsystemctl restart mongod

Method 2 If NO systemd (service mongod restart)

sudo vi /etc/security/limits.d/99-mongodb.conf

Add something like:

*       -       nproc   64000*       -       nofile  64000*       -       fsize   unlimited*       -       cpu     unlimited*       -       memlock unlimited*       -       as      unlimited*       -       rss     unlimited

Note that * it's a wildcard. But you could use a specific user or group.Then restart session and mongod.


Have you tried:

--maxConns arg       max number of simultaneous connections

(Source: mongod documentation)