315157973 commented on code in PR #17456:
URL: https://github.com/apache/pulsar/pull/17456#discussion_r969809607
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java:
##########
@@ -227,4 +236,59 @@ private double updateAvgResourceUsage(String broker,
LocalBrokerData localBroker
return historyUsage;
}
+ private void tryLowerBoundaryShedding(LoadData loadData,
ServiceConfiguration conf) {
+ // Select the broker with the most resource usage.
+ final double threshold =
conf.getLoadBalancerBrokerThresholdShedderPercentage() / 100.0;
+ final double avgUsage = getBrokerAvgUsage(loadData, conf,
canSampleLog());
+ Pair<Boolean, String> result = getMaxUsageBroker(loadData, threshold,
avgUsage);
+ boolean hasBrokerBelowLowerBound = result.getLeft();
+ String maxUsageBroker = result.getRight();
+ BrokerData brokerData = loadData.getBrokerData().get(maxUsageBroker);
+ if (brokerData == null || brokerData.getLocalData() == null
+ || brokerData.getLocalData().getBundles().size() <= 1) {
+ log.info("Load data is null or bundle <=1, broker name is {},
skipping bundle unload.", maxUsageBroker);
+ return;
+ }
+ if (!hasBrokerBelowLowerBound) {
+ log.info("No broker is below the lower bound, threshold is {}, "
+ + "avgUsage usage is {}, max usage of Broker {} is
{}",
+ threshold, avgUsage, maxUsageBroker,
+ brokerAvgResourceUsage.getOrDefault(maxUsageBroker, 0.0));
+ return;
+ }
+ LocalBrokerData localData = brokerData.getLocalData();
+ double brokerCurrentThroughput = localData.getMsgThroughputIn() +
localData.getMsgThroughputOut();
+ double minimumThroughputToOffload = brokerCurrentThroughput *
threshold * LOWER_BOUNDARY_THRESHOLD_MARGIN;
Review Comment:
For example, the min load is 0.49, the avg load is 0.6, the max load is
0.62, and the threshold is 10%. If we directly offload 10% of the max load
broker's throughput, it may lead to the max load broker's load becoming 0.52,
which becomes the min load broker. It will cause offloading bundle with high
frequency.
--
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]