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;
}
网友评论