Skip to content
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

[feat][broker] Support lower boundary shedding for ThresholdShedder #17456

Merged
merged 18 commits into from
Sep 23, 2022

Conversation

315157973
Copy link
Contributor

@315157973 315157973 commented Sep 4, 2022

Motivation

The existing ThresholdShedder has the following problems, for example:
There are 11 Brokers, of which 10 are loaded at 80% and 1 is loaded at 0%.
The average load is 80 * 10 / 11 = 72.73, and the threshold to unload is 72.73 + 10 = 82.73.
Since 80 < 82.73, unload will not be trigger, and there is one idle Broker with load of 0%.

On the basis of ThresholdShedder, we adds the lower boundary judgment of the load.
When 【current usage < average usage - threshold】, the broker with the highest load will be triggered to unload

Modifications

Support lower boundary shedding for ThresholdShedder

Verifying this change

  1. Does not affect the original ThresholdShedder
  2. The new unit test can pass

Documentation

  • [ x ] doc-required
    (Your PR needs to update docs and you will update later)

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Sep 4, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don’t we simply fix the existing class. This new behaviour seems better.

@dave2wave @lhotari

@315157973
Copy link
Contributor Author

We are not sure that the new way completely fine, ThresholdShedder is now the default algorithm, if there are some problems, it will affect the existing business, so we'd better run separately.

@codelipenghui
Copy link
Contributor

As the description of the issue, this appears to be an obvious flaw of the current ThresholdShedder. @315157973 Do you see any negative effects if we push the improvement to ThresholdShedder directly?

@315157973
Copy link
Contributor Author

As the description of the issue, this appears to be an obvious flaw of the current ThresholdShedder. @315157973 Do you see any negative effects if we push the improvement to ThresholdShedder directly?

As I said above, there is no way to guarantee that this new feature will be fully stable, and if something goes wrong, we can't even turn it off.

@Technoboy- Technoboy- added this to the 2.12.0 milestone Sep 5, 2022
@Technoboy- Technoboy- added type/feature The PR added a new feature or issue requested a new feature area/broker labels Sep 5, 2022
@Technoboy- Technoboy- changed the title Add a new range threshold shedder [feat][broker] Add a new range threshold shedder Sep 5, 2022
Copy link
Contributor

@hangc0276 hangc0276 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
This is an improvement of our current ThresholdShedder. I prefer to integrate this improvement into ThresholdSheddger with a flag to turn this feature on.

By default, we can turn it off, after it becomes stable, we can turn it on by default.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core of the question "once it is considered stable".

Who is in charge of doing this testing ?
Choosing between this implementation and the original one is something that nobody would ever do in production.

If you (we) think that this is a bug fix then we have to push it.
We have more that 3 months to see this working on master branch before cutting a new major release (2.12).

@315157973
Copy link
Contributor Author

@eolivelli PTAL

@315157973
Copy link
Contributor Author

Choosing between this implementation and the original one is something that nobody would ever do in production.

Please help CR, I will verify it in production environment

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this addition makes sense as a configuration to modify the ThresholdShedder. I left some comments. Please also include an update to the ThresholdShedder Javadoc so that it is up to date @315157973.

…rviceConfiguration.java

Co-authored-by: Michael Marshall <[email protected]>
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others looks good to me.

private Pair<Boolean, String> getMaxUsageBroker(
LoadData loadData, double threshold, double avgUsage) {
String maxUsageBrokerName = "";
double maxUsage = avgUsage - threshold;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The max usage broker load: > (avgUsage - threshold)
The below lower broker load: < (avgUsage - threshold)

After the max usage broker unloads to the lower broker, the max usage broker might become the lower broker, the lower broker becomes the max usage broker. Can this will lead to frequent bundle unloading?

It looks like we need to change

double minimumThroughputToOffload = brokerCurrentThroughput * threshold * LOWER_BOUNDARY_THRESHOLD_MARGIN;

to

double minimumThroughputToOffload = Math.min(brokerCurrentThroughput * threshold * LOWER_BOUNDARY_THRESHOLD_MARGIN, brokerCurrentThroughput - avgUsage - threshold);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we should also add a test for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not solve the problem.
Unless we know which Bundle is to be unloaded and the load of the Bundle, we can determine whether to select the current Broker. Currently, this Class is only responsible for selecting brokers and cannot know the information about bundles to be unloaded.

The best way to solve this problem is to split bundle.

315157973 and others added 3 commits September 16, 2022 10:41
…ce/impl/ThresholdShedderTest.java

Co-authored-by: Penghui Li <[email protected]>
…ce/impl/ThresholdShedderTest.java

Co-authored-by: Penghui Li <[email protected]>
…ce/impl/ThresholdShedderTest.java

Co-authored-by: Penghui Li <[email protected]>
@codelipenghui
Copy link
Contributor

@315157973 Please also update the PR title, it should be an improvement for the threshold shedder

@315157973 315157973 changed the title [feat][broker] Add a new range threshold shedder [feat][broker] Support lower boundary shedding for ThresholdShedder Sep 21, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
good idea

@dave2wave @MMirelli FYI

@codelipenghui codelipenghui reopened this Sep 22, 2022
@315157973 315157973 merged commit 8e855bc into apache:master Sep 23, 2022
@momo-jun
Copy link
Contributor

@315157973 It will help users understand this feature if you can add the related docs. Do you have any planned updates on that?

@315157973
Copy link
Contributor Author

@315157973 It will help users understand this feature if you can add the related docs. Do you have any planned updates on that?

I'll submit the docs soon.

Technoboy- pushed a commit that referenced this pull request Nov 28, 2022
…17456)

 Support lower boundary shedding for ThresholdShedder (#17456)

The existing ThresholdShedder has the following problems, for example:
There are 11 Brokers, of which 10 are loaded at 80% and 1 is loaded at 0%.
The average load is 80 * 10 / 11 = 72.73, and the threshold to unload is 72.73 + 10 = 82.73.
Since 80 < 82.73, unload will not be trigger, and there is one idle Broker with load of 0%.

On the basis of ThresholdShedder, we adds the lower boundary judgment of the load.
When 【current usage < average usage - threshold】, the broker with the highest load will be triggered to unload
@Technoboy- Technoboy- modified the milestones: 2.12.0, 2.11.0 Nov 28, 2022
@momo-jun
Copy link
Contributor

@315157973 It will help users understand this feature if you can add the related docs. Do you have any planned updates on that?

I'll submit the docs soon.

@315157973 any updates on the docs?

@315157973
Copy link
Contributor Author

momo-jun

Please help review this PR #18675

@momo-jun momo-jun added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.11 doc-complete Your PR changes impact docs and the related docs have been already added. ready-to-test type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants