openresty + lua 这个地方怎么写

329 天前
 awanganddong

lua-resty-upstream-healthcheck lua-resty-balancer

这两个插件是负载均衡和健康检测。组合到一块我不知道怎么写了。

    upstream webserver {
        server 127.0.0.1:12354;
        server 127.0.0.1:12355;
        server 127.0.0.1:12356 backup;
    }
    
  upstream webserver {
        server 127.0.0.1;
        balancer_by_lua_block {
            local b = require "ngx.balancer"
            local swrr_up = package.loaded.my_swrr_up

            -- Note that SWRR picks the first server randomly
            local server = swrr_up:find()
            assert(b.set_current_peer(server))
        }
   }  
    
1201 次点击
所在节点    Lua
1 条回复
awanganddong
329 天前
lua-resty-upstream-healthcheck 和 lua-resty-balancer 不兼容
好像是 init_worker_by_lua_block 执行顺序先于 balancer_by_lua_block 。

可以试试这个库: https://github.com/upyun/lua-resty-checkups

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/950443

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX