I got the seemingly-common "too many file descriptors" error on nginx. After much searching, the solution is clearly to increase the number of file descriptors available to nginx. But there isn't enough info out there for me to feel comfortable doing this in a meaningful and safe way. Here are the main points that most forum/email threads cover:
- the OS has its own total file descriptor limit (on my system,
cat /proc/sys/fs/file-max
outputs "100678") - each user can have their own limit too (but on my system, running
ulimit
as any user outputs "unlimited" see update at bottom with more detail) - a few people said something along the lines of what this person said: 'Directive worker_rlimit_nofile doesn't specify "how many", it is the operating system limit which does. Directive worker_rlimit_nofile just allows a quick-and-dirty way to enlarge this limit if it's not enough.' So I guess the implication is that it's "better" to set the limit for the nginx OS user instead of in the config?
I can just throw in a worker_rlimit_nofile value greater than the number of connections per worker and call it a day, but I feel I don't really know what's going on here.
- why would the limit per worker be less than the OS limit?
- How do I find out what my limit is now?
update: for both root and a normal user, ulimit outputs "unlimited", BUT ulimit -Hn
and ulimit -Sn
both output 1024