RainYuY commented on issue #15762:
URL: https://github.com/apache/dubbo/issues/15762#issuecomment-3552362986

   > > > once the new nodes’ weights reach a certain threshold (say, 30+ or 
higher), the combination of “more new nodes” + “continuously increasing 
weights” will cause requests to be much more likely to hit the new nodes.
   > > 
   > > 
   > > No, I don't think so. Because old nodes will increase their current 
weight faster than new nodes, so they will be selected more frequently than new 
nodes.
   > 
   > The weight of the old nodes is fixed at 100 and never changes, so how 
could they “grow faster”? When an old node is selected, its current becomes a 
large negative value. It then needs to be increased by +100 on each round until 
it reaches a positive value before it has any chance of being selected again.
   > 
   > For a new node, if it is selected, its current will also become a large 
negative value. However, on the next round, because the new node is still in 
the warm-up phase, its current will be reset to 0. In that next round, it will 
then add its current weight (say 70) on top of 0. Under this behavior, the 
probability that the new node is selected again is extremely high.
   
   Because old nodes have a larger weight, they reach a positive value faster 
than new nodes—new nodes always remain at zero. In fact, the weight array does 
not change immediately; these changes take effect only after a selection 
operation is performed. I still cannot reproduce this issue in my test code. 
Here is my test code:
   ``` java
       @Test
       public void testWarnUpPick () throws InterruptedException {
           Invocation invocation = new RpcInvocation(){
               @Override
               public String getMethodName() {
                   return "method1";
               }
               @Override
               public Object[] getArguments() {
                   return new Object[] {"arg1", "arg2", "arg3"};
               }
           };
           AtomicInteger invokerCount = new AtomicInteger(1);
           List<Invoker<LoadBalanceBaseTest>> invokers = new ArrayList<>();
           for (; invokerCount.get() <= 3; invokerCount.getAndIncrement()) {
               invokers.add(getInvoker(invokerCount.get()));
           }
   
           Map<String, Integer> picked = new ConcurrentHashMap<>();
           LoadBalance loadBalance = getLoadBalance(RoundRobinLoadBalance.NAME);
           for (int i = 0; i < 5; i++) {
               Thread a = new Thread(() -> {
                   for (long time = 0; time < 10000000000L; time++) {
   
                       Invoker invoker = loadBalance.select(invokers, 
invokers.get(0).getUrl(), invocation);
                       try {
                           Thread.sleep(0, 100);
                       } catch (InterruptedException e) {
                           throw new RuntimeException(e);
                       }
                       Integer count = 
picked.getOrDefault(invoker.getUrl().toString(), 0);
                       picked.put(invoker.getUrl().toString(), count + 1);
                   }
               });
               a.start();
           }
           for (int j = 0; j < 50; j++) {
               invokers.add(getWarmUpInvoker(invokerCount.getAndIncrement()));
           }
           Long begin = System.currentTimeMillis();
           while (true){
               if (System.currentTimeMillis() - begin > 1000 * 10) {
                   begin = System.currentTimeMillis();
                   for (Map.Entry<String, Integer> entry : picked.entrySet()
                           .stream()
                           .sorted((o1, o2) -> 
-o1.getValue().compareTo(o2.getValue()))
                           .collect(Collectors.toList())) {
                       System.out.println(entry.getKey() + " : " + 
entry.getValue());
                   }
                   System.out.println("--------" + new Date() + 
"------------\n");
                   picked.clear();
               }
           }
   
   
       }
   
   `


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to