Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.