ngx_http_upstream_test_next u->peer.tries > 1

Maxim Dounin mdounin at
Mon Nov 27 13:49:36 UTC 2017


On Fri, Nov 24, 2017 at 03:23:30AM -0500, crasyangel wrote:

> assume all servers always fail in upstream
> nginx would call ngx_http_upstream_next when u->peer.tries > 1, and call
> ngx_http_upstream_finalize_request directly when  u->peer.tries == 1
> it would not pass NGX_PEER_FAILED to u->
> so how peer->fails increase when last retry fail?

The result of the last attempt is returned to the client as is, 
and it is not considered to be a failure regardless of other 
settings.  In the edge case when there is only one server, 
requests are simply passed to the server.

If there is more than one server, and all servers fail, the first 
request will disable all servers but the last one (assuming 
default max_fails=1), and the second request will disable the last 

Maxim Dounin

More information about the nginx mailing list