MongoDB Documentation, Release 3.0.4 • You can limit the number of incoming connections using the maxIncomingConnections run-time option. By restricting the number of incoming connections you can prevent a cascade effect where the mongos creates too many connections on the mongod instances. • mongos instances maintain a connection pool to each shard so that the mongos can reuse connections and quickly fulfill requests without needing to create new connections. Note: Changed in version 2.6: MongoDB removed the upward limit on the maxIncomingConnections setting. ulimit You can use the ulimit command at the system prompt to check system limits, as in the following example: 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. You can change ulimit settings by issuing a command in the following form: 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 recom- mended 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 . On OS X, use the launchctl limit command. See your operating system documentation for the precise procedure for changing system limits on running systems. Chapter 5. Administration 288 $ 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) 40000 -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 -n <value> Review and Set Resource Limits