【发布时间】:2013-05-30 22:59:00
【问题描述】:
如何增加 nginx 中的文件描述符限制?
增加文件描述符有几种方法:
编辑
/etc/security/limits.conf并为 nginx 用户设置 nofile 软硬限制。在
/etc/default/nginx中设置$ULIMIT。 nginxinit.d脚本设置 ulimit $ULIMIT https://gist.github.com/aganov/1121022#file-nginx-L43在
nginx.confhttp://wiki.nginx.org/NginxHttpMainModule#worker_rlimit_nofile中设置worker_rlimit_nofile
在启动时使用init.d 脚本在limits.conf 中设置限制会影响nginx 吗?
我必须在初始化脚本中使用 ulimit $ULIMIT 还是可以使用 worker_rlimit_nofile 代替?
在 init 脚本中使用 ulimit $ULIMIT 时,是否还需要使用 worker_rlimit_nofile 为每个 worker 设置限制?
谢谢
【问题讨论】:
-
被警告这可能有副作用。有关 ServerFault 的更多信息 in this great answer。
标签: nginx file-descriptor