美文网首页
dubbo的负责均衡策略详解

dubbo的负责均衡策略详解

作者: 藤原咸鱼 | 来源:发表于2022-01-06 11:39 被阅读0次

    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;
    }
    

    相关文章

      网友评论

          本文标题:dubbo的负责均衡策略详解

          本文链接:https://www.haomeiwen.com/subject/nfnlcrtx.html