Maximum number of backends to try

Maxim Dounin mdounin at
Tue Apr 6 12:25:14 MSD 2010


On Mon, Apr 05, 2010 at 09:46:52PM -0400, bryndole wrote:

> The only such patch I could find was this:  
> Which only works with the memcached_gzip plugin of which it is a 
> part. 

For me, 1st google result points to author's site ( with 
the patch posted alone.

Your google may vary though.

> I too would find this feature extremely helpful. Preventing the 
> situation where some request takes just a bit too long and times 
> out on server or generates the "wrong" type of error and nginx 
> tries upstream server after upstream server, without bound.
> Any other suggestions? Is anyone working on a simpler patch?

Usually people just disable proxy_next_upstream (or limit it to 
something like "error") and use error_page based fallback instead.  

    upstream backend {
        # many servers here

    location / {
        proxy_pass http://backend;
        error_page 502 504 = @fallback;

    location @fallback {
        proxy_pass http://backend;

Maxim Dounin

More information about the nginx mailing list