How to increase the Mongodb connection limit?

Asked

Viewed 802 times

0

Good morning. I have an Ubuntu 16.04 LTS server, hosted on Linode. Last night I spent all night reading articles and testing settings to increase Mongodb’s connection capacity, but nothing worked. At the moment Mongo has 819 available, which would be 80% of 1024.

I tried to increase the file limit with the command ulimit -n 64000 but the same only affects my user, and after relocating back to 1024.

I changed the file /etc/sysctl.conf and added the line fs.file-max = 64000, but it didn’t work.

I changed the file /etc/security/limits.conf and added the following lines, one by one to test (always restarting the server between each change):

* - nofile 64000 root - nofile 64000 mongodb - nofile 64000 mongodb - nproc 64000

After this configuration the ulimit -a returns:

core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 48041 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 64000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 48041 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

I created the file /etc/security/limits.d/99-mongodb-nproc.conf with the configuration * - nofile 64000 and it didn’t work either.

I also put the line session required pam_limits.so in the archives /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive and nothing.

Man /etc/systemd/system/mongod.service is running mongod with the argument --maxConns 51200 and the mongo.conf is with maxIncomingConnections: 51200

When I execute the command db.serverStatus().connections in the shell of Mongo, he returns to me { "current" : 9, "available" : 810, "totalCreated" : NumberLong(68349) }.

I don’t know what else to try. Someone can help me?

  • Good morning @ataquino, did you ever restart the server? these changes involve modifying the kernel parameters and may require a reboot of the machine.

  • I forgot to inform that every change I restarted the service and if it did not work I would restart the server.

1 answer

3


I got help out of stackoverflow and apparently it’s a bug of version 3.2.8: https://jira.mongodb.org/browse/SERVER-25080.

On another server I have version 3.2.11 installed, but even repeating all the above steps did not work. I ended up applying the workaround contained in this link and it worked:

For my system I made a Quick fix by Creating file named /etc/systemd/system/mongod.service. d/ulimit.conf (you should create mongod.service.d directory, file name itself is arbitrary) with following Contents:

[Service]
Limitfsize=Infinity
Limitcpu=Infinity
Limitas=Infinity
Limitnofile=64000
Limitnproc=64000

Browser other questions tagged

You are not signed in. Login or sign up in order to post.