You can use the ulimit command at the system prompt to check system limits, as in the following example:

copy $ ulimit -a -t: cpu time ( seconds ) unlimited -f: file size ( blocks ) unlimited -d: data seg size ( kbytes ) unlimited -s: stack size ( kbytes ) 8192 -c: core file size ( blocks ) 0 -m: resident set size ( kbytes ) unlimited -u: processes 192276 -n: file descriptors 21000 -l: locked-in-memory size ( kb ) unlimited -v: address space ( kb ) unlimited -x: file locks unlimited -i: pending signals 192276 -q: bytes in POSIX msg queues 819200 -e: max nice 30 -r: max rt priority 65 -N 15 : unlimited

ulimit refers to the per-user limitations for various resources. Therefore, if your mongod instance executes as a user that is also running multiple processes, or multiple mongod processes, you might see contention for these resources. Also, be aware that the processes value (i.e. -u ) refers to the combined number of distinct processes and sub-process threads.

On Linux, you can change ulimit settings by issuing a command in the following form:

copy ulimit -n <value>

There are both “hard” and the “soft” ulimit s that affect MongoDB’s performance. The “hard” ulimit refers to the maximum number of processes that a user can have active at any time. This is the ceiling: no non-root process can increase the “hard” ulimit . In contrast, the “soft” ulimit is the limit that is actually enforced for a session or process, but any process can increase it up to “hard” ulimit maximum.

A low “soft” ulimit can cause can't create new thread, closing connection errors if the number of connections grows too high. For this reason, it is extremely important to set both ulimit values to the recommended values.

ulimit will modify both “hard” and “soft” values unless the -H or -S modifiers are specified when modifying limit values.

For many distributions of Linux you can change values by substituting the -n option for any possible value in the output of ulimit -a .

After changing the ulimit settings, you must restart the process to take advantage of the modified settings. On Linux, you can use the /proc file system to see the current limitations on a running process.

Depending on your system’s configuration, and default settings, any change to system limits made using ulimit may revert following a system restart. Check your distribution and operating system documentation for more information.

macOS¶ For macOS systems that have installed MongoDB Community using the brew installation method, the recommended open files value is automatically set when you start MongoDB through brew services . See Run MongoDB with brew for more information. For macOS systems running MongoDb Enterprise or using the TGZ installation method, use the launchctl limit command to set the recommended values. See your operating system documentation for the precise procedure for changing system limits on running systems.