-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: manual
-
Labels:
Documentation should cover the OS settings required to run mongodb at scale.
Discussion:
The Linux OS limits cover number of open files/sockets per process, number of threads per user, and various other per-process limits. If these are set too low, mongod/mongos will fail with various errors.
For mongod running standalone or in a replica set (non-sharded):
- One thread is allocated for each connection to the 'mongod' process
- One file descriptor is used by each incoming connection
- One file descriptor is used for each data file or journal file used by the database
For mongos (running in a sharded cluster):
- One thread is allocated for each incoming connection from a client
- One file descriptor is used by each incoming connection
- One file descriptor is used for a connection to each member of each shard
Here are the values I'd recommend for the 'ulimit' settings for the MongoDB processes:
- file size (-f) unlimited
- cpu time (-t) unlimited
- virtual memory (-v) unlimited
- open files (-n) 21000
- memory size (-m) unlimited
- processes/threads (-u) 32000
Diagnosing problems:
On Linux, users can determine the limits for the mongod/mongos processes by examining the contents of the file /proc/$PID/limits, where $PID is the process ID of the mongod/mongos process in question.