http-status-code-404 - 如果后端服务器之一关闭,haproxy 将在大约 2-3 秒内出现 404 错误
问题描述
这是 haproxy 配置。
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 错误(取决于 inter 值,如果 inter 值非常小,404 错误的数量会减少)。
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-21:5 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.111. :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 /tsturl1 4080 POST 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,原因:Layer7错误状态,code:404,info:“Not Found”,检查时长: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\
我的问题是:为什么参数重试不起作用?即使其中一个后端服务器宕机,用户是否总是得到 200 码而不是 400 错误?我使用的是 Haproxy 1.5.18。
多谢
解决方案
推荐阅读
- tensorflow - 输入图像与预期模型输入图像之间的形状不兼容
- r - RStudio:仅显示以前代码的结果
- c - 我想用这个函数打印素数。我的错误在哪里?
- bash - 将 bash 转换为 fish 函数(在 fish 中使用 rga-fzf)
- javascript - Infinitegrid 中每行一项
- javascript - React JS 对购物车进行分组
- python - 通过匹配多行对 Pandas Dataframe 进行排序
- firefox - 设置 Last-Modified 标头时,Firefox 总是缓存
- inno-setup - 用 Inno Setup 的 setup 子文件夹中的文件覆盖已安装的文件
- c++ - Visual Studio 2019 不强调 C++ 项目中的错误