aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_upstream_ip_hash_module.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2011-10-12 14:22:48 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2011-10-12 14:22:48 +0000
commitb713e480ca9aeccaf63bccf8629eec13041c6ab6 (patch)
tree8e2715dced608b399c3a4d7157bee7519e4380f9 /src/http/modules/ngx_http_upstream_ip_hash_module.c
parent72df0f400a4f6144f9c69add91002a0ff02cfe41 (diff)
downloadnginx-b713e480ca9aeccaf63bccf8629eec13041c6ab6.tar.gz
nginx-b713e480ca9aeccaf63bccf8629eec13041c6ab6.zip
Better recheck of dead upstream servers.
Previously nginx used to mark backend again as live as soon as fail_timeout passes (10s by default) since last failure. On the other hand, detecting dead backend takes up to 60s (proxy_connect_timeout) in typical situation "backend is down and doesn't respond to any packets". This resulted in suboptimal behaviour in the above situation (up to 23% of requests were directed to dead backend with default settings). More detailed description of the problem may be found here (in Russian): http://mailman.nginx.org/pipermail/nginx-ru/2011-August/042172.html Fix is to only allow one request after fail_timeout passes, and mark backend as "live" only if this request succeeds. Note that with new code backend will not be marked "live" unless "check" request is completed, and this may take a while in some specific workloads (e.g. streaming). This is believed to be acceptable.
Diffstat (limited to 'src/http/modules/ngx_http_upstream_ip_hash_module.c')
-rw-r--r--src/http/modules/ngx_http_upstream_ip_hash_module.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index dffbf22b2..4c031eb47 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -185,8 +185,8 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
break;
}
- if (now - peer->accessed > peer->fail_timeout) {
- peer->fails = 0;
+ if (now - peer->checked > peer->fail_timeout) {
+ peer->checked = now;
break;
}
}