https://www.haproxy.com/blog/failover-and-worst-case-management-with-haproxy/
Normal backup servers: In this case, s3 will be used first, until it fails, then s4 will be used. frontent ft_app bind 10.0.0.1:80 default_backend bk_app_main backend bk_app_main server s1 10.0.0.101:80 check server s2 10.0.0.102:80 check server s3 10.0.0.103:80 check backup server s4 10.0.0.104:80 check backup Multiple backup servers: In this case, both s3 and s4 will be used if they are available. option allbackups frontent ft_app bind 10.
https://serverfault.com/questions/480241/nginx-failover-without-load-balancing
pstream backend { server 1.2.3.4:80 fail_timeout=5s max_fails=3; server 4.5.6.7:80 backup; } server { listen 80; server_name whatevs.com; location / { proxy_pass http://backend; } } https://www.cnblogs.com/biglittleant/p/8979887.html
backup 预留的备份服务器,当其他所有的非backup服务器出现故障或者忙的时候,才会请求backup机器,因为这台集群的压力最小。
max_fails 允许请求失败的次数,默认是1,当超过最大次数时,返回proxy_next_upstream模块定义的错误。0表示禁止失败尝试,企业场景:2-3.京东1次,蓝汛10次,根据业务需求去配置。
fail_timeout,在经历了max_fails次失败后,暂停服务的时间。京东是3s,蓝汛是3s,根据业务需求配置。常规业务2-3秒合理。
例:如果max_fails是5,他就检测5次,如果五次都是502.那么,他就会根据fail_timeout 的值,等待10秒,再去检测。
https://blog.51cto.com/wangwei007/1103727