2

Is setting the right value of worker_rlimit_nofile in nginx.conf enough solve the issue of Too many open files in nginx?

Or do I still need to update the sysctl.conf and limits.conf?

Ryan
  • 5,831
  • 24
  • 72
  • 91

2 Answers2

4

In Linux, you can see if that option has changed the limits of the process by running:

cat /proc/<PID>/limits

Where <PID> is the process ID of nginex. Test on a development environment.

If that option is not changing the limits or if you have a too restrictive hard limit you need to change the nofile in the /etc/security/limits.conf file.

Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
0

I do not think you need to modify limits.conf. The point of worker_rlimit_nofile is to provide a quick and dirty way to do this via RLIMIT_NOFILE.

However, there are hard system limits set by the OS which you may need to override using sysctl.conf.

In practice, I usually set my fs.file-max in sysctl to about 4X the rlimit for my apps. No basis for this other than I never want something to fail due to hitting this limit. And a 2-4X range is usually sufficiently high to only trigger when there's a major issue with the apps.

jeffatrackaid
  • 4,142
  • 19
  • 22