[alibaba/tengine]Tengine 2.1.1 健康检查进程间不协调工作

2024-08-21 580 views
6

Hi 最近发现当 tengine 添加了大量 upstream 并配置 upstream check 的情况下,会出现健康检查进程间不同步的现象。 使用版本:2.1.1 现象描述: upstream check 配置

check interval=5000 rise=1 fall=1 timeout=2000 type=http default_down=false;
check_keepalive_requests 100;
check_http_send "GET /someuri HTTP/1.0\r\nConnection:keep-alive\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;

为了方便追踪进程对健康页面的调用情况,我把 checkuri 设为了一个不可访问的地址, 然后发现 error.log 打印出以下内容(为了便于说明问题,我抽取了三个进程号):

2015/11/19 18:32:16 [error] 16768#0: check protocol http error with peer: 10.15.133.33:80 
2015/11/19 18:32:21 [error] 16770#0: check protocol http error with peer: 10.15.133.33:80 
2015/11/19 18:32:23 [error] 16773#0: check protocol http error with peer: 10.15.133.33:80 
2015/11/19 18:32:23 [error] 16768#0: check protocol http error with peer: 10.15.133.33:80 
2015/11/19 18:32:26 [error] 16770#0: check protocol http error with peer: 10.15.133.33:80 
2015/11/19 18:32:23 [error] 16773#0: check protocol http error with peer: 10.15.133.33:80 

按照我的理解, upstream check 的预期行为应该是进程间协调工作对 upstream server 进行健康检查,由于 timeout = 2000,所以这里看到的信息应该是每 7000 ms 出现一个 check protocol http error。 按照现实情况来看,每一个进程单独进行了 upstream check,每隔 7000ms 进行一次健康检查。

这样的话,单个后台服务器的健康检查页面增加了 process_num 的倍。 我们目前还没有找到触发问题的最小测试集,但这个现象出现得还是比较频繁的。

请问 tengine 在压测中有没有出现过类似的问题?或者能否告知可能导致这个现象的原因以便我们排错。

回答

8

按照我对源码的理解,每个work 进程是独立进行健康监测的,他们之间不会彼此协调,只是共享后端server 的健康监测状态...

2

这个是有协同工作的,我们会查看不协同的情况。

3

checkuri 10.15.133.33:80 的这个不可用url是配置在一个upstream中的么? 还是配置在了多个upstream中?

如果配置在多个upstream中, 加上unique=true 在测测看。 check interval=5000 rise=1 fall=1 timeout=2000 type=http default_down=false unique=true;

4

配置在一个 upstream 中的,其他 upstream 与这个 upstream 的 upstream server member 完全一致,只是名字不一样,但是保证每个 upstream check uri 都是唯一的。在排查的时候,我保证了只有一个 upstream 的 healthcheck 页面不可访问,其他 healthcheck 页面全部返回 2xx,所以这里看的 error 一定是针对那一个 upstream 的健康检查失效。

9

对于不同Upstream中的相同server member,我了解的情况是不会合并,而是会分别检查,实际上也互相独立。至于unique这个参数,我理解的还不够清楚。

4

分开检查没有错也没出错,只是在 upstream check 的时候发现进程工作没有协调。我相信这个问题不是由于是否 unique 导致。:)

8

麻烦把upstream的配置贴一下吧

7

配置如下: upstream 的区别只是 xxx 这里不一样。

upstream backend_xxx {
    server 192.168.12.1:80 weight=1 max_fails=10 fail_timeout=10;
    server 192.168.12.2:80 weight=1 max_fails=10 fail_timeout=10;
    server 192.168.12.3:80 weight=1 max_fails=10 fail_timeout=10;
    server 192.168.12.4:80 weight=1 max_fails=10 fail_timeout=10;
    check interval=5000 rise=1 fall=1 timeout=2000 type=http default_down=false;
    check_keepalive_requests 100;
    check_http_send "GET /upstreamxxx/healthcheck.html HTTP/1.0\r\nConnection:keep-alive\r\n\r\n";
    check_http_expect_alive http_2xx http_3xx;
}
8

hi, 我没有复现, 麻烦把所有upstream配置都发一下吧 然后注明下那个检查是失败的 thx 我测试的日志,间隔都还正常, 每个进程都协调工作:

2015/12/15 13:37:43 [error] 5551#0: disable check peer: 127.0.0.1:8080 
2015/12/15 13:37:48 [error] 5549#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:37:53 [error] 5548#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:37:59 [error] 5550#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:38:05 [error] 5551#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:38:10 [error] 5549#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:38:15 [error] 5548#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:38:22 [error] 5550#0: check protocol http error with peer: 127.0.0.1:8080 
2015/12/15 13:38:28 [error] 5551#0: check protocol http error with peer: 127.0.0.1:8080 
2

好的,我整理下给你。

2

请问能给个邮箱地址吗?

9

lieyuan@taobao.com

8

发现问题了,我们的版本是添加了 bugfix: upstream check for dynamic #642 patch 的版本,然后只要进行过 dyups 操作,health check 就会出现问题。

0

使用之前 merge 的版本是不会有重复 check 的问题的。

1

merge 操作还是要的,否则多个 process 都会往里面加 peer_shm。只是要更细粒度的 merge。

0

@cfsego @xiaokai-wang @taoyuanyuan pull request #678 针对这个问题的简单描述和修复。麻烦帮忙看下有没有问题。