首页 > 其他 > 详细

Nginx频繁报“500 Internal Server Error”错误

时间:2021-01-19 20:02:18      阅读:42      评论:0      收藏:0      [点我收藏+]

有一台服务器某天因为促销活动导致访问量激增,频繁报“500 Internal Server Error”错误。我查了一下nginx的错误日志(apt-get方式安装的nginx的错误日志在/var/log/nginx/error.log),发现了大量的“[alert] xxxxx#0: accept() failed (24: Too many open files)”
11655386 socket() failed (24: Too many open files) while connecting to upstream,

我上网查了一下,说这是超过了最大打开文件数的限制。

还有现在worker_process 还是4 最好调成8 和cpu核数一样 这样才能充分用到多核
然后最好也顺便把net.ipv4.ip_local_port_range 调成1024-65000 这样当负载真上去了 nginx自己的本地端口不会用完

解决方法是:
查看最大打开文件数
ulimit -a

1 打开/etc/security/limits.conf文件,加上两句

  • soft nofile 655350
  • hard nofile 655350

2 打开/etc/nginx/nginx.conf
在worker_processes的下面增加一行
worker_rlimit_nofile 65535;
3 重新启动nginx,重新载入设置

Nginx频繁报“500 Internal Server Error”错误

原文:https://www.cnblogs.com/wuxingwang/p/14297578.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!