Good morning. I have an Ubuntu 16.04 LTS server, hosted on Linode. Yesterday I spent all night reading articles and testing settings to increase the connection capacity of MongoDB, but nothing worked. At the moment the mongo is with 819 available, that would be 80% of 1024.
I have tried to increase the limit of file descriptors with the command ulimit -n 64000
but it only affects my user, and after relogar back to 1024.
I changed the file /etc/sysctl.conf
and added the line fs.file-max = 64000
, but it did not 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 setting 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 also did not work.
I also put the session required pam_limits.so
line in the files /etc/pam.d/common-session
and /etc/pam.d/common-session-noninteractive
and nothing.
My /etc/systemd/system/mongod.service
is running mongod with argument --maxConns 51200
and mongo.conf
is with maxIncomingConnections: 51200
When I run the db.serverStatus().connections
command in the mongo shell, it returns me { "current" : 9, "available" : 810, "totalCreated" : NumberLong(68349) }
.
I do not know what to try anymore. Can anyone help me?