Search code examples
linuxmongodbulimit

what is nproc and nofile in ulimits?


I would like to know what nofile and nproc in ulimits is for, preferably with examples. Specifically, what is their role in database?


Solution

  • With respect to mongodb the two parameters are as follows:

    nofile: -n: file descriptors

    • This ulimit settings parameters tells how many file descriptor a mongodb process can use. MongoDB internally uses file for storing connections, journal files, indexes and datafiles.
    • MongoDB recommeneds to set nofile to 64000. However, you may need to change it to higher values based on your requirement(with WiredTiger storage engine in particular). Provided you do testing on your environments using these values.

    nproc: -u: processes/threads

    • MongoDB uses processes to track each internal thread or pthread as a system process. e.g replication thread

    • MongoDB shows a startup warning if nproc is not set as expected. This is generally set as 1/2 of the nofile for mongodb deployments