2

I have configured Nginx load balancing between backend servers.

upsteam backend {
    server 127.0.0.1:8080;
    server 127.0.0.1:8081;
    server 127.0.0.1:8082;
    server 127.0.0.1:8083;
}

server {
    ...
    location / {
        ...
        proxy_pass http://backend;
    }
}

A bad request came in, backend app could not handle it and it crashed. So Nginx tried each server from upstream with the request, taking down all app instances. Is it possible to tell Nginx to try at most for example half of the servers from upstream before returning an error response?

2
  • 2
    I don't think there's any way to do this. However, there are plenty of ways to automatically restart a crashed app server. And quite a few ways to fix bugs in app code. – Michael Hampton Sep 3 '14 at 22:00
  • @MichaelHampton Of course, app servers are running under supervisord and cause of the crash is already fixed. Thank you for your smart comment... – Jakub Kulhan Sep 4 '14 at 1:32
1

I know its very late for an answer but I had this issue and came across this question.

You could use proxy_next_upstream_tries 2;

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.