Nginx as load balancer – what happens with not responded requests?

gotha asked:

I have 2 VPS servers with PHP applications that both use the same database ( on 3rd server).
I want to have 4th server with just nginx as load balancer to try to “divide” the traffic in two.

My questions is – what is going to happen if nginx recieves a request, tries to forward it to one of the servers but the server does not respond.
Is it going to try to send it to the second server or not ?

It is important for me not have a single lost request, so if Server1 fails, Server2 is going receive the same request immediately.
Is this how nginx works ? If not, can I do it with nginx or I should try using another solution ?

Regards.

My answer:


You can set the proxy_next_upstream parameter to set the error conditions when nginx will retry a request on another upstream proxy server.

For example:

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.