https://github.com/rrfeng/lua-resty-upstream-etcd/
在我这个从 etcd 动态获取 upstream 的模块中,根据 nginx 的 round robin 算法引入了权重的支持。
https://github.com/phusion/nginx/commit/27e94984486058d73157038f7950a0a36ecc6e35
现在想实现的是 slow_start 参数,因为这个功能是商业版的没有源码可以抄(汗),所以可以看到在 lua-resty-upstream-etcd 里快速实现一个方法
方式是发现一个 peer 新加入的时候,那么开启一个 timer 来定时修改 peer.weight 值,直到恢复正常。
看了一下 tengine 也没有相关的实现,只有一个 pr 也是很久了。而且它这个是直接在 round robin 里实现的,引入了一个 uptime 的参数。
不能确定哪种方式更好……
求指点。
另外引入 slow_start 之后势 weight 必有 float 出现,然后各个 peer 的 effective_weight 就变成了 1.0000000001, 2.999999998 这样的……应该不会影响性能吧??