Today, we found that nginx has a lot of 499 errors, accounting for nearly 0.5%, and it was after a new service with upstream was launched.
Grep nginx source code, defined in 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
It is clear that this is a status code defined by nginx, used to indicate such an error: Before the server returns an http header, the client closes the http connection in advance.
Then, in grep, "NGX_HTTP_CLIENT_CLOSED_REQUEST", it is found that the current status value is only assigned in ngx_upstream.
Upstream returns 499 in the following situations:
(1) Before receiving a read/write event, upstream checks whether the connection is available: ngx_http_upstream_check_broken_connection,
If (c-> error) {// connecttion error
...... If (! U-> cacheable) {// The value of cacheable of upstream is false, which is related to the setting of the http_cache module. Indicates whether the content is cached. Ngx_http_upstream_finalize_request (r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST );}}
As shown in the preceding code, 499 is returned when a connection error occurs.
(2) The server does not end processing the request, but the client closes the connection in advance, and 499 is returned.
(3) If an upstream error occurs, when executing next_upstream, the connection is also determined to be available. If the connection is unavailable, 499 is returned.
In short, the increase in the percentage of this error may indicate that the upstream processing on the server is too slow, resulting in the user closing the connection in advance. Under normal circumstances, a small proportion is normal.
Nginx details: click here
Nginx: click here
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4