16

i need your help in solving this

this is the result of my ulimit -a on my linux server

 core file size (blocks, -c) 0 scheduling priority (-e) 0 file size (blocks, -f) unlimited max memory size (kbytes, -m) unlimited open files (-n) 10000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 24576 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited 

Right now this is the result of my MongoDB

db.serverStatus().connections { "current" : 4, "available" : 5996 } 

I want to increase the MongoDb connections more to 10000 .

I have tried different options like in my mongod1.conf

fork = true port = 27017 maxConns = 10000 

and also this while starting mongodb

mongod ulimit -n 10000 --config mongod1.conf 

but nothing worked and all failed , please let me know how can i increase the connections to 10000 in my case , thanks in advance .

4
  • What is the maximum allowed file descriptor value in your /proc/sys/fs/file-max? You need to bump that up too. Commented May 23, 2013 at 12:24
  • i have updated the enteries as per the request Commented May 23, 2013 at 12:28
  • 1
    You need to have the maximum file descriptions more than 10000 since your background processes use some of them. ulimit -n 25000 should do it. Commented May 23, 2013 at 12:37
  • thanks Kashyap , but how can i change that to 25000 ?? Commented May 23, 2013 at 12:45

5 Answers 5

8

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/

Sign up to request clarification or add additional context in comments.

Comments

6

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=infinity LimitCPU=infinity LimitAS=infinity LimitMEMLOCK=infinity LimitNOFILE=64000 LimitNPROC=64000 

Then execute:

systemctl daemon-reload systemctl 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.

1 Comment

Thanks it did work for me like a charm. Waster couple of hours to understand the root issue.
4

Have you tried:

--maxConns arg max number of simultaneous connections 

(Source: mongod documentation)

Comments

4

It seems MongoDB has no limit on incoming connections and you should modify system-wide limit, see official doc:

Unless constrained by system-wide limits, MongoDB has no limit on incoming connections. On Unix-based systems, you can modify system limits using the ulimit command, or by editing your system’s /etc/sysctl file. See UNIX ulimit Settings for more information.

Recommended ulimit Settings(offical doc):

-f (file size): unlimited

-t (cpu time): unlimited

-v (virtual memory): unlimited

-n (open files): 64000

-m (memory size): unlimited

-u (processes/threads): 64000

Remember to restart your mongod and mongos instances after changing the ulimit settings to ensure that the changes take effect.

Source: number-of-connections recommended-ulimit-settings

1 Comment

I don't think Mongod can accept unlimited number of connections. The global default is 65536
1

You might need to change the hard limits in /etc/limits.conf or /etc/security/limits.conf depending on your distribution.

Comments