HAProxy balance b/w 多个后端不工作

HAProxy balance b/w multiple backends is not working

我的haproxy配置如下:

defaults
  log global
  mode http
  timeout connect 5000ms
  timeout client 50000ms
  timeout server 50000ms
  timeout queue 50000ms
  timeout http-request 60000ms
  timeout http-keep-alive 5000ms
  max-keep-alive-queue 10
  option httplog
  option redispatch
  option forwardfor
  option http-server-close

frontend front
  bind *:80
  acl use_bar nbsrv(foo) -m int lt 1
  use_backend bar if use_bar
  default_backend foo

backend foo
  server foo1 10.0.0.1:80 check

backend bar
  server bar1 10.0.1.1:80 check
  server bar2 10.0.1.2:80 check

我的问题是,如果 backend foo 关闭,那么对代理的第一个请求将失败,并显示 503 服务不可用。

后续调用在代理到 backend bar 时工作。

在任何情况下,我们都不希望 API 调用失败。

我通过保留单个后端并使用服务器作为备份来修复它:

defaults
  log global
  mode http
  timeout connect 5000ms
  timeout client 50000ms
  timeout server 50000ms
  timeout queue 50000ms
  timeout http-request 60000ms
  timeout http-keep-alive 5000ms
  max-keep-alive-queue 10
  option httplog
  option redispatch
  option forwardfor
  option http-server-close

frontend front
  bind *:80
  default_backend foo

backend foo
  server foo1 10.0.0.1:80 check
  server bar1 10.0.1.1:80 check backup
  server bar2 10.0.1.2:80 check backup