You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/03/01 08:16:04 UTC
[GitHub] [incubator-shenyu] AhahaGe opened a new issue #2957: [Question]
AhahaGe opened a new issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957
### Question
First is in HashLoadBalancer, see below code, can ConcurrentSkipListMap be replaced by SortedMap as we do not need concurrency logic.
`public Upstream doSelect(final List<Upstream> upstreamList, final String ip) {
final ConcurrentSkipListMap<Long, Upstream> treeMap = new ConcurrentSkipListMap<>();
upstreamList.forEach(upstream -> IntStream.range(0, VIRTUAL_NODE_NUM).forEach(i -> {
long addressHash = hash("SHENYU-" + upstream.getUrl() + "-HASH-" + i);
treeMap.put(addressHash, upstream);
}));
long hash = hash(ip);
SortedMap<Long, Upstream> lastRing = treeMap.tailMap(hash);
if (!lastRing.isEmpty()) {
return lastRing.get(lastRing.firstKey());
}
return treeMap.firstEntry().getValue();
}`
Second, in AbstractLoadBalancer class, see below code will method calculateWarmupWeight always return 1, as uptime always slower than warmup, and weight is always int and > 1;
`private int getWeight(final long timestamp, final int warmup, final int weight) {
if (weight > 0 && timestamp > 0) {
int uptime = (int) (System.currentTimeMillis() - timestamp);
if (uptime > 0 && uptime < warmup) {
return calculateWarmupWeight(uptime, warmup, weight);
}
}
return weight;
}
private int calculateWarmupWeight(final int uptime, final int warmup, final int weight) {
int ww = (int) ((float) uptime / ((float) warmup / (float) weight));
return ww < 1 ? 1 : (Math.min(ww, weight));
}`
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1055501539
If weight is 1 and uptime slower than warmup, ww is 1.
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1056114102
int ww = (int) ((float) 250 / ((float) 500 / (float) 50));
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair removed a comment on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair removed a comment on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1055502035
If weight is 1 and uptime slower than warmup, `ww` is 1.
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1055502872
If weight is 1 and uptime slower than warmup, `ww` is 0.
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] AhahaGe commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
AhahaGe commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1056030127
> If weight is 1 and uptime slower than warmup, `ww` is 0.
yes, I mean ww is always between 0 and 1, so ww is 1, and Math.min(ww,weight) is of no use?
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1055502035
If weight is 1 and uptime slower than warmup, `ww` is 1.
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair removed a comment on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair removed a comment on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1055501539
If weight is 1 and uptime slower than warmup, ww is 1.
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] AhahaGe commented on issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
AhahaGe commented on issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957#issuecomment-1056125186
> int ww = (int) ((float) 250 / ((float) 500 / (float) 50));
many thanks
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-shenyu] KevinClair closed issue #2957: [Question]
Posted by GitBox <gi...@apache.org>.
KevinClair closed issue #2957:
URL: https://github.com/apache/incubator-shenyu/issues/2957
--
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@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org