Nginx 499 报错,tomcat大量超时

今天web大量超时报错,查看日志显示,tomcat链接RPC服务timeout,查看tomcat机器和RPC服务所在机器资源都正常。尝试重启RPC服务后,web仍然报错,查看nginx日志,有大量499报错。经查询得知,nginx的499报错解释如下:

『 499 / ClientClosed Request
    An Nginx HTTP server extension. This codeis introduced to log the case when the connection is closed by client whileHTTP server is processing its request, making server unable to send the HTTP header back』

原因可能是服务端处理时间太长了,看一下upstream_response_time时间可以了解到后端程序处理了多久。

先了解一下什么是upstream_response_time和request_time分别是什么:

request_time:服务端从接受客户端请求的第一个字节到服务端应用程序处理完发送完响应数据的时间,包括请求数据时间、程序响应时间、输出响应时间
upstream_response_time:指nginx向后端如php,tomcat等建立连接开始到到处理完数据关闭连接为止的时间。

查看nginx日志,果然upstream_response_time和request_time都很大,猜测是后台处理太慢,导致客户端主动断开了链接。

最后查看db服务器,发现cpu使用率和内存使用率都很高,进而查看『show processlist』,发现mysql处理一条更新花费了很多时间,因为前两天升级了web的内存和cpu,增大了kvm的内存。应该是tomcat集群处理速度提高,导致db压力负载过大,sql处理的太慢,客户端等待时间太长,用户主动断开连接。

解决:

升级db服务器的cpu,从8核升级到16核,果然,web不在超时,nginx不再报499错误。

时间: 2024-07-28 18:10:45

Nginx 499 报错,tomcat大量超时的相关文章

Nginx启动报错:

Nginx启动报错:10013: An attempt was made to access a socket in a way forbidden 2014-08-07 14:39:10   来源:   评论:0 点击: Nginx在win7,win2008下启动报错:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permis

Nginx启动报错:10013: An attempt was made to access a socket in a way forbidden

Nginx在win7,win2008下启动报错:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions) . 原因是Win7下nginx默认80端口被System占用,造成nginx启动报错的解决方案. 在cmd窗口运行如下命令: [plain] C:\Users\Administrator>netstat -ao

FastDFS整合nginx后,nginx一直报错

FastDFS整合nginx后,nginx一直报错: 报错内容: [2018-06-11 09:41:21] ERROR - file: ../common/fdfs_http_shared.c, line: 148, param "http.mime_types_filename" not exist or is empty 处理过程: #include http.conf是写在/etc/fdfs/mod_fastdfs.conf里,然而在 /etc/fdfs目录中没有 http.c

nginx启动报错:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo

一.背景 这个错误在重启nginx或者启动nginx的时候,经常会出现.我之前也一直认为出现这个错误是因为有程序占用了nginx的进程.但是知其然不知其所以然.每次报错都有点懵逼,所以这边一步步排查错误,做个记录. 二.排错过程 1.按照提示 //按照提示,执行此命令,查看错误原因 systemctl status nginx.service 由报错信息可知,nginx绑定80端口失败.详细错误请输入 -l 继续查看 2.继续跟踪错误 //查看错误的详情 systemctl status ngi

windows tomcat 启动报错TOMCAT JAVA_HOME or JRE_HOME environment variable is not defined correctly

问题描述: TOMCAT JAVA_HOME or JRE_HOME environment variable is not defined correctly 报错信息如下:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program;提示找不到java_home各jre

nginx访问报错:Too many open files accept:

使用nginx作为web服务,访问的时候报错:accept() failed (24: Too many open files) 原因时:nginx的连接数超过了系统设定的最大值! 解决办法:(1)[[email protected] nginx]# ulimit -n1024 [[email protected] nginx]# ulimit -n 655360 #把打开文件数设置足够大,这是临时修改方案[[email protected] nginx]# ulimit -n655360 (2

生产环境nginx代码报错500

2015年11月23日晚搭建完BRS系统(上传图片系统)后,测试机器功能发现无法图片无法上传到服务器上,查看nginx日志后发现日志nginx状态码返回500(内部服务器错误), 1.开始认为是nginx权限导致,把upload目录改为777,但是依然无效,后思考下如果是权限问题不应该返回500,而是403之类的状态码,后开始进行下一步排查: 2.后利用google的调试功能进行排查,后发现貌似数据库报错,插入不了数据,有的字段未显示但还不能为空,所以插入不进去数字,原因在于数据库配置问题,后把

nginx编译报错处理

下载nginx安装包 wget http://nginx.org/download/nginx-1.9.15.tar.gz && tar xvf nginx-1.9.15.tar.gz && cd nginx-1.9.15 ./configure 这一步是发生报错: ./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by u

nginx 启动报错

这个问题的出现应该是系统找不到nginx的配置文件nginx.conf,所以,我们要告诉系统配置文件的位置: 使用nginx -c /usr/local/nginx/conf/nginx.conf 再执行/usr/local/nginx/sbin/nginx -t 测试一下: 如果不报错,则执行/usr/local/nginx/sbin/nginx -s reload