我使用nginx来提供静态文件,并作为Erlang IM服务器的代理。 每个用户使用两个长轮询http连接。 操作系统是Ubuntu的服务器。
在繁忙时间,我看到:
> sudo more /proc/sys/fs/file-nr 1024 0 38001
在正常的时间,文件描述符的数量低于1024,但从不超过1024.当我达到1024的限制时,用户报告连接丢失。
尽piperoot用户(erlang),www-data用户(nginx)和打开的TCP连接每个都低于1024,但为什么受限于1024个文件描述符? 有一些全球性的1024限制吗?
我是否需要在nginx中使用worker_rlimit_nofile,或者是否足够在所有用户的limits.conf中增加nofile?
谢谢
更多信息可能是相关的:
> sudo nano /etc/security/limits.conf ... root hard nofile 30000 root soft nofile 30000 > sudo sysctl fs.file-max fs.file-max = 38001 > ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 4160 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 4160 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
除root以外的另一个用户最有可能达到您的文件描述符限制。
尝试切换/etc/security/limits.conf
... * hard nofile 30000 * soft nofile 30000
这样每个用户的上限为30000。