4

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

braaterAfrikaaner
  • 1,072
  • 10
  • 20
yogesh.j
  • 51
  • 1
  • 4
  • 1
    do you know about a thing called searching the internet? When I search for `linux nofile` there are 490000 results. When I serach for `linux nproc` there are 125000 results. ..... – shellter Feb 10 '18 at 02:41
  • 1
    StackOverflow is about helping people fix their existing programming code. Edit your Q to show sample inputs/outputs and your best attempt at coding a solution to your problem. Sorry, but **requests for tutorials, research**, tools, recommendations, libraries, and free coding services are off-topic. ***Please*** read https://stackoverflow.com/help/on-topic , https://stackoverflow.com/help/how-to-ask , https://stackoverflow.com/help/dont-ask , https://stackoverflow.com/help/mcve and take the [tour](https://stackoverflow.com/tour) before posting more Qs here. Good luck – shellter Feb 10 '18 at 02:41

1 Answers1

8

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

Atish
  • 4,277
  • 2
  • 24
  • 32
  • Thanks for ur valuable time I hav one scenario that we have add one secondry server n started intial sync with parameter only nofile upto 64000 and nproc upto 1024. it is feasible for new secondry to stay up. – yogesh.j Feb 10 '18 at 09:53
  • If you look at the mongodb init script, it sets the nproc to -u 64000. In your case setting lower value will end up sending a startup warning and may cause any possible problems when nproc(1024) eventually reached – Atish Feb 10 '18 at 12:54
  • as u have describe me above what is nproc as per that when processes used MongoDB will increase then issue will occur ryt – yogesh.j Feb 10 '18 at 18:01
  • setting this value to lesser than what required will cause an issue – Atish Feb 10 '18 at 18:21