me小怪兽

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

nginx报accept4( ) failed (24: Too many open files)

生产环境因为并发量突然增大,导致系统登录页面刷新、访问失败报500

查看nginx后台错误日志,发现频繁打印accept4() failed (24: Too many open files)

[yunwei@nginx ~]# tail -f /usr/local/openresty/nginx/logs/error.log
2022/11/21 08:40:36 [alert] 28808#28808: *57325374 socket() failed (24: Too many open files) while connecting to upstream, client: 172.25.100.227, server: , request: "POST /nginx/api/data/nginxDataCheck HTTP/1.1", upstream: "http://10.30.40.56:8009/data/nginxDataCheck", host: "172.25.102.126:20002"
2022/11/21 08:40:36 [crit] 28808#28808: accept4() failed (24: Too many open files)
2022/11/21 08:40:37 [alert] 28808#28808: *57325398 socket() failed (24: Too many open files) while connecting to upstream, client: 172.25.100.227, server: , request: "POST /nginx/api/data/nginxDataCheck HTTP/1.1", upstream: "http://10.30.40.56:8009/data/nginxDataCheck", host: "172.25.102.126:20002"
2022/11/21 08:40:37 [crit] 28808#28808: accept4() failed (24: Too many open files)

原因:日志里的接口也是合法的,外人是不可能访问的,大概率是nginx的系统配置没有优化,大并发访问时nginx性能堵塞

解决方法:修改vi /etc/nginx/conf/nginx.conf配置文件

#允许使用cpn数量
worker_processes 4;

events {

#进程数
worker_connections 2048;
}
#进程最大打开文件数
worker_rlimit_nofile 65536;

 

#重启加载nginx

nginx -s reload

posted on   me小怪兽  阅读(529)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示