-
使用ngx_http_dyups_module模块,在节点宕机后会间隔丢失请求
-
某个服务节点宕机后,ngx_http_upstream_check_module健康检查没有生效,每10秒会给宕机节点发一个请求,nginx日志显示返回code是502;在使用dyups模块前是正常的
-
期望结果:节点宕机后,在恢复(tcp心跳正常)前都不给转发请求到宕机节点
-
重现过程:upstream配置如下,kill进程(10.110.14.130:7347),连续请求im-test.lietou.com
file: /usr/local/nginx/conf/upstream.conf
upstream my-test.lietou.com {
server 10.110.14.206:7347;
server 10.110.14.130:7347;
check interval=2000 rise=1 fall=2 timeout=1000 type=tcp;
}
server {
listen 80;
server_name im-test.lietou.com;
proxy_next_upstream off;
set $access_filter "on";
set $ups "my-test.lietou.com";
location /{
proxy_pass http://$ups;
}
}
- access日志
10.110.252.55 [26/Apr/2019:23:17:10 +0800] GET /publish/error?editMode=1&code=200 HTTP/1.1 "200" 1077 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0" "-"
... 200 status ... snipped...
"502" 7590 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0" "-" "-" "0.002" "0.002" "-" 10.110.14.130:7347 "im-test.lietou.com" "-" "-" "-" "http" "-"
10.110.252.55 [26/Apr/2019:23:17:16 +0800] GET /publish/error?editMode=1&code=200 HTTP/1.1 ..
...200 status ... snipped...
"502" 7590 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0" "-" "-" "0.001" "0.001" "-" 10.110.14.130:7347 "im-test.lietou.com" "-" "-" "-" "http" "-"
10.110.252.55 [26/Apr/2019:23:17:32 +0800] GET /publish/error?editMode=1&code=200 HTTP/1.1
errorr日志:
2019/04/26 23:17:00 [error] 7006#0: *256491 connect() failed (111: Connection refused) while connecting to upstream, client: 10.110.252.55, server: im-test.lietou.com, request: "GET /publish/error?editMode=1&code=200 HTTP/1.1", upstream: "http://10.110.14.130:7347/publish/error?editMode=1&code=200", host: "im-test.lietou.com"
2019/04/26 23:17:14 [error] 7006#0: *256491 connect() failed (111: Connection refused) while connecting to upstream, client: 10.110.252.55, server: im-test.lietou.com, request: "GET /publish/error?editMode=1&code=200 HTTP/1.1", upstream: "http://10.110.14.130:7347/publish/error?editMode=1&code=200", host: "im-test.lietou.com"
2019/04/26 23:17:27 [error] 7006#0: *256491 connect() failed (111: Connection refused) while connecting to upstream, client: 10.110.252.55, server: im-test.lietou.com, request: "GET /publish/error?editMode=1&code=200 HTTP/1.1", upstream: "http://10.110.14.130:7347/publish/error?editMode=1&code=200", host: "im-test.lietou.com"
- 环境:tengine-2.2.1,centos7