问题描述
这是haproxy配置.
this is the haproxy config.
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 httpchk HEAD /sabrix/scripts/menu-common.js
server host1 11.11.11.11:9080 check inter 2000 rise 1 fall 2
server host2 11.11.11.12:9080 check inter 2000 rise 1 fall 2
如果11.11.11.11的服务关闭,则haproxy将在大约2-3秒内收到503和404错误(这取决于中间值,如果中间值非常大,则取决于中间值小,则会减少404错误的数量.)
if service of 11.11.11.11 is down, haproxy will get 503 and 404 error about 2-3 seconds( it depends inter value, if inter value is verysmall, the number of 404 error will be decreased).
2020-08-25T11:58:14 11.11.11.11:9080 200 POST/tsturl1 HTTP/1.1 2274
2020-08-25T11:58:14 11.11.11.22:9080 200 POST/tsturl1 HTTP/1.1 448
2020-08-25T11:58:14 11.11.11.11:9080 503 POST/tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 404 POST/tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 200 POST/tsturl1 HTTP/1.1 1503
2020-08-25T11:58:16 11.11.11.22:9080 200 POST/tsturl1 HTTP/1.1 617
2020-08-25T11:58:16 11.11.11.11:9080 404 POST/tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 11.11.11.22:9080 200 POST/tsturl1 HTTP/1.1 618
2020-08-25T11:58:16 11.11.11.11:9080 404 POST/tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 host1关闭,原因:Layer7错误状态,代码:404,信息:未找到",检查持续时间:0ms.还剩1台活动服务器和0台备用服务器.活动的会话数为0,重新排队的为0,队列中剩余的为0.2020-08-25T11:58:16 11.11.11.22:9080 200 POST/tsturl1 HTTP/1.1 645
2020-08-25T11:58:16 11.11.11.22:9080 200 POST/tsturl1 HTTP/1.1 618 \
2020-08-25T11:58:14 11.11.11.11:9080 200 POST /tsturl1 HTTP/1.1 2274
2020-08-25T11:58:14 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 448
2020-08-25T11:58:14 11.11.11.11:9080 503 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 200 POST /tsturl1 HTTP/1.1 1503
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 617
2020-08-25T11:58:16 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 618
2020-08-25T11:58:16 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 host1 is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 645
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 618\
我的问题是:为什么参数重试不起作用?即使后端服务器之一发生故障,用户是否总能得到200条代码而不是400条错误?我正在使用Haproxy 1.5.18.
My question is :why the parameter retry didn't work ? is it possible for the user always get 200 code rather than 400 error even when one of the backend server down ?I'm using Haproxy 1.5.18.
非常感谢
推荐答案
在您使用的版本中,重试
用于第4层(即连接超时).HAProxy 2.0引入了第7层重试.这2条博客文章可能会有所帮助:
In the version you are using retries
is for Layer 4 (i.e. connection timeout). HAProxy 2.0 introduced Layer 7 retries. These 2 blog posts may be helpful:
这篇关于如果后端服务器之一关闭,则haproxy将在大约2-3秒内收到404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!