dubbo的負(fù)責(zé)均衡策略
1.權(quán)重隨機(jī)算法的 RandomLoadBalance
2.加權(quán)輪詢算法的 RoundRobinLoadBalance (加權(quán)平滑輪詢,基于LVS,最大公約數(shù)輪詢算法)
3.最少活躍調(diào)用數(shù)算法的 LeastActiveLoadBalance
4.hash 一致性的 ConsistentHashLoadBalance
加權(quán)平滑輪詢算法過程
加權(quán)平滑輪詢算法資料
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;
}