nginx 修改 max open files limits

注意:修改 nginx 的 max open files 有个前提,就是你已经修改好了系统的 max open files.nginx

先查看 nginx 的 ulimit:
grep 'open files' /proc/$( cat /var/run/nginx.pid )/limitsubuntu

修改 nginx.servicebash

sudo vi /lib/systemd/system/nginx.service  # (仅适用于 ubuntu)
复制代码

添加:并发

[Service]
LimitNOFILE=100000
复制代码

重启服务: sudo systemctl daemon-reloadspa

修改 nginx.conf, 添加:rest

worker_rlimit_nofile 90000;  # (has to be smaller or equal to LimitNOFILE set above)
复制代码

重启 nginx: sudo systemctl restart nginxcode

上面是网上流传的教程,可是仍是不够,你这样改了以后,nginx 的并发能力反而会降低,因此还须要改一个关键的参数: 修改 nginx.conf 添加:教程

events {
    worker_connections  90000;
}
复制代码

重启 nginx: sudo systemctl restart nginxit

相关文章
相关标签/搜索