nginx 修改 max open files limits


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

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

修改 nginx.service

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

添加:

[Service] LimitNOFILE=100000 复制代码

重启服务: sudo systemctl daemon-reload

修改 nginx.conf, 添加:

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

重启 nginx: sudo systemctl restart nginx

上面是网上流传的教程,但是还是不够,你这样改了之后,nginx 的并发能力反而会下降,所以还需要改一个关键的参数: 修改 nginx.conf 添加:

events { worker_connections 90000; } 复制代码

重启 nginx: sudo systemctl restart nginx

关注下面的标签,发现更


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM