加权轮询算法

2021-09-28 21:17

阅读:833

标签:个数   this   range   serve   dex   data-   title   edit   start   func (this *LoadBalance) RoundRobinByWeight() *HttpServer { server := this.Servers[ServerIndices[this.CurIndex]] this.CurIndex = (this.CurIndex + 1) % len(ServerIndices) //ServersIndices存放的是按照权重排放的索引,如3,1,2 则ServerIndices=[0,0,0,1,2,2] 然后遍历ServerIndices可以拿到按照权重得到的索引,在每一次遍历中用索引得到[3,1,2]对应的index,一个数的余数只能是0到他自己 return server }来自为知笔记(Wiz)加权轮询算法标签:个数   this   range   serve   dex   data-   title   edit   start   原文地址:https://www.cnblogs.com/hualou/p/12070688.html


评论


亲,登录后才可以留言!