failover to the next upstream server if one of the servers is slow

ebondar nginx-forum at
Fri Jun 22 22:50:24 UTC 2018


i'm trying to setup a failover configuration between two upstream servers,
all works as expected. But i want to cover the case if one of the upstream
servers is became a very slow and i want to remove this servers from
rotation and move all requests to the second upstream server.

upstream rubyfe {

server {
        listen       443 http2;
        gzip on;
        proxy_connect_timeout       300;
        proxy_send_timeout          300;
        proxy_read_timeout          300;
        send_timeout                300;
        proxy_buffering on;
        location / {
                proxy_read_timeout 1;
                proxy_pass         https://rubyfe;
                proxy_next_upstream     error timeout invalid_header
http_500 http_502 http_503 http_504;
                proxy_next_upstream_timeout 3;

when i tried to load the first server 
#stress --cpu 80 --io 8 --vm 4 --vm-bytes 300M --timeout 180s

# wrk -t2 -c20 -d30s

in log files i catched request from "wrk" - - [22/Jun/2018:17:59:10 -0400] "GET / HTTP/1.1" 200 50393 "-"
"-" "-" ", [ 1.001, 0.814 ]" "text/html;
charset=utf-8" "-" "582bd020659715d66afafad533f7ac5d"

but at this time i tried to get result via "curl" i seen

$ curl -IL
HTTP/1.1 502 Bad Gateway

could you help me to understand how i can operate timeouts of requests to
the upstream servers and in case if one of the upstream server became is
slow to force requests switch to another server

Posted at Nginx Forum:,280259,280259#msg-280259

More information about the nginx mailing list