You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "magicxiexiaodong (via GitHub)" <gi...@apache.org> on 2023/03/09 07:07:53 UTC

[GitHub] [dubbo] magicxiexiaodong opened a new issue, #11776: RandomLoadBalance 方法 权重定位性能优化

magicxiexiaodong opened a new issue, #11776:
URL: https://github.com/apache/dubbo/issues/11776

   我阅读Dubbo RandomLoadBalance 源码时发现定位Invoker 使用的算法是遍历,如下
     ```
   int[] weights = new int[length];
           // The sum of weights
           int totalWeight = 0;
           for (int i = 0; i < length; i++) {
               int weight = getWeight(invokers.get(i), invocation);
               // Sum
               totalWeight += weight;
               // save for later use
               weights[i] = totalWeight;
               if (sameWeight && totalWeight != weight * (i + 1)) {
                   sameWeight = false;
               }
           }
           if (totalWeight > 0 && !sameWeight) {
               // If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on totalWeight.
               int offset = ThreadLocalRandom.current().nextInt(totalWeight);
               // Return a invoker based on the random value.
               for (int i = 0; i < length; i++) {
                   if (offset < weights[i]) {
                       return invokers.get(i);
                   }
               }
           }
   ```
   使用weights数组 最后在遍历 时间复杂度为O(N) ,如果服务端的服务特别大的话性能不太好,所以我想可以优化成O(logN)的算法
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] eye-gu commented on issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "eye-gu (via GitHub)" <gi...@apache.org>.
eye-gu commented on issue #11776:
URL: https://github.com/apache/dubbo/issues/11776#issuecomment-1475764015

   If this task is currently unoccupied, I would like to give it a try. I think it can use binary search. @AlbumenJ 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] 24kpure commented on issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "24kpure (via GitHub)" <gi...@apache.org>.
24kpure commented on issue #11776:
URL: https://github.com/apache/dubbo/issues/11776#issuecomment-1471785764

   Wow ~ Looking forward for O(logN).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #11776:
URL: https://github.com/apache/dubbo/issues/11776#issuecomment-1477525824

   We can follow up in this issue if anyone have some ideas.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ closed issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ closed issue #11776: RandomLoadBalance 方法 权重定位性能优化
URL: https://github.com/apache/dubbo/issues/11776


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #11776:
URL: https://github.com/apache/dubbo/issues/11776#issuecomment-1466018552

   Please submit a PR if you have any ideas?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] eye-gu commented on issue #11776: RandomLoadBalance 方法 权重定位性能优化

Posted by "eye-gu (via GitHub)" <gi...@apache.org>.
eye-gu commented on issue #11776:
URL: https://github.com/apache/dubbo/issues/11776#issuecomment-1477579562

   Let me try. Please assigne the issue to me @AlbumenJ 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org