-
Notifications
You must be signed in to change notification settings - Fork 828
[SBC-870]refactor to using custom RuleExt, not using Robin IRule. #883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| List<AtomicInteger> stats = new ArrayList<>(servers.size()); | ||
| int totalWeights = 0; | ||
| boolean needRandom = false; | ||
| for (ServiceCombServer server : servers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每次都进行重新计算,如果server很多的时候,会影响性能吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
权重算法就是这样的。对我们的场景,这个计算量很少,以及过滤掉不可用实例了。 即使200实例,这个算法复杂度也很低。比原来的Robin的WeightedResonseTimeRule要快,它的计算量更多。而且现在还省去了timer的后台计算。 现在是简单权重算法,来换取可靠性,不追求权重的精确性。
| } | ||
| this.policy = policy; | ||
| this.strategy = strategy; | ||
| LoadBalancer loadBalancer = getOrCreateLoadBalancer(invocation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to make loadBalancer statless
1.invoke discoveryTree before getOrCreateLoadBalancer
2.getOrCreateLoadBalancer
3.send or sendWithRetry with server list
chooseServer with server list
create RetryLoadBalancer instance with server list
| String strategy = Configuration.INSTANCE.getRuleStrategyName(invocation.getMicroserviceName()); | ||
| boolean isRuleNotChanged = isEqual(policy, this.policy) && isEqual(strategy, this.strategy); | ||
| if (!isRuleNotChanged) { | ||
| if (!isEqual(strategy, this.strategy)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to check if customers being using old policy configuration, and tell them how to switch to new mechanism
check can be done when init, not when handle
currently maybe init method not invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
| @Override | ||
| public IRule createLoadBalancerRule(String ruleName) { | ||
| public RuleExt createLoadBalancerRule(String ruleName) { | ||
| if (RULE_RoundRobin.equals(ruleName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
support SPI?
and use a map to manage them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the extension point is ExtensionsFactory, not RuleExt. Maybe we can work RuleExt based on SPI in future, now no need to give so many extension points.
| List<AtomicInteger> stats = new ArrayList<>(servers.size()); | ||
| int totalWeights = 0; | ||
| boolean needRandom = false; | ||
| for (ServiceCombServer server : servers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calc weight for every invocation is not a good idea
| boolean needRandom = false; | ||
| for (ServiceCombServer server : servers) { | ||
| ServiceCombServerStats serverStats = ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServerStats(server); | ||
| int avgTime = (int) serverStats.getAverageResponseTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avg result better to be double
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles, where you replaceSCB-XXXwith the appropriate JIRA issue.mvn clean installto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.