如果响应时间超过2000毫秒,则将haproxy后端服务器之一标记为已关闭

问题描述

我的haproxy.cfg是:

global
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4096
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

defaults
  option forwardfor
  log global
  option httplog
  log 127.0.0.1 local3
  option  dontlognull
  retries 3
  option redispatch
  timeout connect 5000ms
  timeout client  5000ms
  timeout server 5000ms


listen stats
    bind    *:9000
    mode    http
  ..................................
..............................................

backend testhosts
    mode http
    balance roundrobin 
    option tcplog
    option tcp-check
#    cookie SERVERID
    option httpchk HEAD /sabrix/scripts/menu-common.js
    server host1 11.11.11.11:9080 check cookie host1
    server host2 22.22.22.22:9080 check cookie host2

日志显示:

2020-08-19T16:02:14+08:00 localhost haproxy[22439]: Server Host2 is DOWN,reason: Layer7 timeout,check duration: 2000ms. 1 active and 0 backup servers left. 0 sessions active,0 requeued,0 remaining in queue.
2020-08-19T16:02:14+08:00 localhost haproxy[22439]: Server Host2 is DOWN,0 remaining in queue.
2020-08-19T16:02:18+08:00 localhost haproxy[12706]: Server Host2 is DOWN,check duration: 2001ms. 1 active and 0 backup servers left. 0 sessions active,0 remaining in queue.
2020-08-19T16:02:19+08:00 localhost haproxy[12706]: Server Host2 is DOWN,0 remaining in queue.
2020-08-19T16:02:27+08:00 localhost haproxy[12706]: Server Host2 is UP,reason: Layer7 check passed,code: 200,info: "OK",check duration: 138ms. 2 active and 0 backup servers online. 0 sessions requeued,0 total in queue.
2020-08-19T16:02:30+08:00 localhost haproxy[22439]: Server Host2 is UP,check duration: 1ms. 2 active and 0 backup servers online. 0 sessions requeued,0 total in queue.
2020-08-19T16:02:30+08:00 localhost haproxy[12706]: Server Host2 is UP,check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued,0 total in queue.

at that time( when the host is marked as down), the call result will be 504 error rather than 200.

2020-08-19T20:16:02+08:00 localhost haproxy[3774]: 39898  22.22.22.22 504 POST /url/services
2020-08-19T20:16:02+08:00 localhost haproxy[3774]: 39909  11.11.11.11 200 POST /url/services

我的问题: 我已将超时设置为5000ms,为什么后端服务器#2的响应时间超过2000ms时报告了错误?我可以增加超时来消除错误吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)