nginx upstream health check参数说明

在nginx中我们新建upstream的server时候一般会如下配置

1
2
3
4
upstream webserver {
server 192.168.101.2:8888 max_fails=10 fail_timeout=2s;
server 192.168.101.3:8888 max_fails=10 fail_timeout=2s;
}

nginx官方文档里这样写的:

max_fails=number
sets the number of unsuccessful attempts to communicate with the server that should happen in the duration set by the fail_timeout parameter to consider the server unavailable for a duration also set by the fail_timeout parameter. By default, the number of unsuccessful attempts is set to 1. The zero value disables the accounting of attempts. What is considered an unsuccessful attempt is defined by the proxy_next_upstream, fastcgi_next_upstream, uwsgi_next_upstream, scgi_next_upstream, memcached_next_upstream, and grpc_next_upstream directives.

fail_timeout=time
sets
the time during which the specified number of unsuccessful attempts to communicate with the server should happen to consider the server unavailable;
and the period of time the server will be considered unavailable.
By default, the parameter is set to 10 seconds.

这里写的都比较简单,max_fails 这个就是失败次数, fail_timeout 就是超时时间。

那么问题来了,这里的max_fails的失败是指什么,超时? 网络无法连接? 502? 504? 这个是多久时间内的呢?