comparison src/http/modules/ngx_http_upstream_ip_hash_module.c @ 4207:4fc91bae6f83

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 12 Oct 2011 14:22:48 +0000
parents 2e91aecb9e57
children d620f497c50f
comparison
equal deleted inserted replaced
4206:1a94a56a4e5d 4207:4fc91bae6f83
183 183
184 if (peer->max_fails == 0 || peer->fails < peer->max_fails) { 184 if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
185 break; 185 break;
186 } 186 }
187 187
188 if (now - peer->accessed > peer->fail_timeout) { 188 if (now - peer->checked > peer->fail_timeout) {
189 peer->fails = 0; 189 peer->checked = now;
190 break; 190 break;
191 } 191 }
192 } 192 }
193 193
194 iphp->rrp.tried[n] |= m; 194 iphp->rrp.tried[n] |= m;