nginx 499返回码
来源:互联网 发布:mac flamingo口红 编辑:程序博客网 时间:2024/05/01 16:55
今天发现nginx有不少的499错误,大约占了将近0.5%,而且是在新上线了一个含upstream的业务之后。
grep一下nginx源码,定义在ngx_request_t.h
/*
* HTTP does not define the code for the case when a client closed
* the connection while we are processing its request so we introduce
* own code to log such situation when a client has closed the connection
* before we even try to send the HTTP header to it
*/
#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
这下就很清楚了,这是nginx定义的一个状态码,用于表示这样的错误:服务器返回http头之前,客户端就提前关闭了http连接。
再grep下“NGX_HTTP_CLIENT_CLOSED_REQUEST”,发现目前这个状态值只在ngx_upstream中赋值。
upstream在以下几种情况下会返回499:
(1)upstream在收到读写事件处理之前时,会检查连接是否可用:ngx_http_upstream_check_broken_connection,
if (c->error) { //connecttion错误
……
if (!u->cacheable) { //upstream的cacheable为false,这个值跟http_cache模块的设置有关。指示内容是否缓存。
ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST);
}
}
如上代码,当连接错误时会返回499。
(2)server处理请求未结束,而client提前关闭了连接,此时也会返回499。
(3)在一个upstream出错,执行next_upstream时也会判断连接是否可用,不可用则返回499。
总之,这个错误的比例升高可能表明服务器upstream处理过慢,导致用户提前关闭连接。而正常情况下有一个小比例是正常的。
文章出自http://www.itnose.net/news/160/6280560
- nginx 499返回码
- 使用Nginx+lua返回错误码并且返回自定义内容。
- nginx重定向,返回301状态码
- Nginx HTTP返回状态码修改
- nginx直接返回
- nginx 返回json
- Nginx 返回 json
- Nginx自定义404错误页面并返回404状态码
- Nginx handler 返回值解释
- nginx 返回数据被截断
- Nginx自定义404错误页面,返回200状态码,非404状态码解决!
- nginx返回chunked编码的问题
- Nginx PHP 返回200,但是空白页
- 让nginx始终返回gzip内容
- 上传操作 nginx 返回413的处理
- nginx+django httpresponse返回中文编码问题
- nginx返回file not found原因
- nginx部署webSocket时返回403
- vim基本命令
- flex兼容性
- 从零开始学习音视频编程技术(三) 开发环境搭建
- 导航控制器
- weUI应用,用JS封装了几个常用的信息提示的弹层
- nginx 499返回码
- 深入浅出Android Gradle构建系统(三:build task)
- TypeError: 'datetime.datetime' object is not iterable [duplicate]
- php防止SQL注入详解及防范(输入过滤,输出转义)
- 母版页
- 视频播放的基本原理
- NETIF_FLAG_LINK_UP的意义和作用
- makefile相关链接
- CentOS目录结构超详细版