dubbo的负责均衡策略详解

dubbo的负责均衡策略
1.权重随机算法的 RandomLoadBalance
2.加权轮询算法的 RoundRobinLoadBalance (加权平滑轮询,基于LVS,最大公约数轮询算法)
3.最少活跃调用数算法的 LeastActiveLoadBalance
4.hash 一致性的 ConsistentHashLoadBalance

加权平滑轮询算法过程
加权平滑轮询算法资料
lvs核心算法如下:

/*
Supposing that there is a server set S = {S0, S1, …, Sn-1};
W(Si) indicates the weight of Si;
i indicates the server selected last time, and i is initialized with -1;
cw is the current weight in scheduling, and cw is initialized with zero; 
max(S) is the maximum weight of all the servers in S;
gcd(S) is the greatest common divisor of all server weights in S;
*/
while (true) {
    i = (i + 1) mod n;
    if (i == 0) {
        cw = cw - gcd(S); 
        if (cw <= 0) {
            cw = max(S);
            if (cw == 0)
            return NULL;
        }
    } 
    if (W(Si) >= cw) 
        return Si;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容