[openresty] 关于自定义upstream 主动health check(lua-resty-upstream-healthcheck,nginx_upstream_check_module )

86 views
Skip to first unread message

wayne Z

unread,
Dec 3, 2024, 12:03:23 AM12/3/24
to openresty
Hi,
目前正在研究upstream节点的主动检测,
主要需求是当节点 inactive时,可以自动下掉,变为active时,可以自动上线,并且兼容默认的路由策略,例如 least_conn, rand-robin, consist-hash等等。
由于节点inactive时,虽然可以正常提供接口服务,但是其数据已经不正确了。
一般的端口检测或者发送head/get请求,然后判断http状态码是否为2XX并不能判断节点是否为active。
所以需要通过发送一个请求到节点(GET/POST),然后通过返回的结果数据(json格式)判断。

问题1:
调研了淘宝实现的https://github.com/yaoweibin/nginx_upstream_check_module/tree/master ,需要在其基础上修改代码,增加指令和处理函数才可能满足需求;但也有资料说 openresty的高版本不支持nginx_upstream_check_module,请问是否真的如此?

问题2:
调研的时候,发现了lua-resty-upstream-healthcheck(https://opm.openresty.org/package/openresty/lua-resty-upstream-healthcheck/),请问是否能满足需求?


wayne Z

unread,
Dec 3, 2024, 11:16:29 PM12/3/24
to openresty

Hi,
关于问题1,在macOS上编译运行没有问题,Linux平台代测试,请忽略此问题。

问题2,查了资料,目前还没有发现有自定义  response 的handler,所以还需要继续再研究一下。



wayne Z <shiz...@gmail.com> 于2024年12月3日周二 13:02写道:
Reply all
Reply to author
Forward
0 new messages