Aias00 opened a new issue, #7973:
URL: https://github.com/apache/shenyu/issues/7973

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues
   
   ### Current Behavior
   
   `ShortestResponseLoadBalancer` computes `succeededAverageElapsed * 
inflight`, but neither its selection path nor Divide's shortestResponse 
completion path updates `inflight`. A fresh upstream starts at 1, so this 
usually compares historical successful average latency only. A historically 
fast upstream continues to receive requests even as its pending queue grows.
   
   ### Expected Behavior
   
   Maintain outstanding request accounting for this strategy, paired across 
request start and all terminal signals, so increasing concurrency affects the 
estimate.
   
   ### Steps To Reproduce
   
   Create two healthy upstreams A and B with equal positive weights. Set both 
inflight values to 1, and initialize successful response metrics:
   
   ```java
   a.getSucceeded().set(1);
   a.getSucceededElapsed().set(10);
   b.getSucceeded().set(1);
   b.getSucceededElapsed().set(100);
   var balancer = new ShortestResponseLoadBalancer();
   int aHits = 0;
   for (int i = 0; i < 100; i++) {
       if (balancer.select(List.of(a, b), new LoadBalanceData()) == a) {
           aHits++;
       }
   }
   System.out.println(aHits);                 // observed: 100
   System.out.println(a.getInflight().get()); // observed: 1
   ```
   
   Do not complete requests between selections. The result was reproduced 
against the commit below. In Divide, the shortestResponse callback only records 
successful elapsed time and count; it does not fix the missing inflight 
accounting.
   
   ### Anything else?
   
   - Selection: 
https://github.com/apache/shenyu/blob/862f5e37e894bd8cef85ef540a8629f313e9ecdf/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/spi/ShortestResponseLoadBalancer.java#L43-L49
   - Completion metrics: 
https://github.com/apache/shenyu/blob/862f5e37e894bd8cef85ef540a8629f313e9ecdf/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/DividePlugin.java#L201-L208
   - Related but different issue: #6544 addressed the start-time race, not 
missing inflight accounting.
   
   ### Environment
   
   - ShenYu: master, 2.7.2-SNAPSHOT
   - Commit: `862f5e37e894bd8cef85ef540a8629f313e9ecdf`
   - Java 17
   
   


-- 
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]

Reply via email to