Skip to content

[BUG] shortestResponse does not track inflight requests and ignores growing queue depth #7973

Closed

Description

@Aias00

Is there an existing issue for this?

  • 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:

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?

Environment

  • ShenYu: master, 2.7.2-SNAPSHOT
  • Commit: 862f5e37e894bd8cef85ef540a8629f313e9ecdf
  • Java 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions