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

   ## Description
   `doSelect` allocates a fresh `ConcurrentSkipListMap` and, for every upstream 
x 5 virtual nodes, calls `hash("SHENYU-" + upstream.getUrl() + "-HASH-" + i)` 
which does `MessageDigest.getInstance("MD5")` (JCA lookup + new instance), 
`key.getBytes(UTF_8)`, and `md5.digest()` (new `byte[]`). The ring is never 
cached; it is fully rebuilt on every selection even though the upstream set 
only changes on health-check/admin events.
   
   ## Location
   ```
   shenyu-loadbalancer/.../spi/HashLoadBalancer.java:44-56 (doSelect), 58-77 
(hash)
   ```
   
   ## Impact
   Per hash-LB request: 1 SkipListMap + 5*N MD5 instances + 5*N String 
concatenations + 5*N `byte[]` digests. For N=10 upstreams that's 50 MD5 
hashes/request. Very high CPU + allocation on the sticky/consistent-hash path; 
scales linearly with RPS and upstream count.
   
   ## Suggested fix
   Build and cache the ring (e.g. `ConcurrentHashMap<String, 
TreeMap<Long,Upstream>>` keyed by selectorId, invalidated when 
`UpstreamCacheManager.submit`/health-check mutates the list). Use a 
`ThreadLocal<MessageDigest>` or a faster non-crypto hash (murmur3/xxHash). 
Precompute virtual-node keys when the upstream list changes.
   
   ## Related existing issue(s)
   None
   
   _Identified during the 2026-08-02 audit; full list in 
[`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._


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