我在access 阶段 从mysql 取得一个 2维 tables,是 ip +port,相应的后端server信息读出来 保存在ngx.ctx中。然后怎么在upstream中利用balancer_by_lua进行轮询什么的? --
hello,1. 在 balancer_by_lua 里,你一样可以通过 ngx.ctx 获取到你保存的 table2. 轮询就看你需要什么要的策略了,简单的用 math.random 来随机都行https://github.com/openresty/lua-nginx-module/blob/balancer-by-lua/t/133-balancer.t#L55ps:access 阶段可以不用每次都去 mysql 读取(当然还是得看你的需求),可以使用 Lua VM 内的全局缓存,比如 lua-resty-lrucachehttps://github.com/openresty/lua-resty-lrucache在 2015年11月4日 下午2:42,Hadals Yang <hadal...@gmail.com>写道:我在access 阶段 从mysql 取得一个 2维 tables,是 ip +port,相应的后端server信息读出来 保存在ngx.ctx中。然后怎么在upstream中利用balancer_by_lua进行轮询什么的? --