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

[Broker] Add time based backlog quota #10093

Merged
merged 8 commits into from Apr 21, 2021

Conversation

MarvinCai
Copy link
Contributor

@MarvinCai MarvinCai commented Mar 30, 2021

Motivation

As discussed in issue #9680, although we can use message TTL to expire the backlogs of the subscription, but it'll still be good to have a time based backlog quota so broker can apply proper back pressure strategy when quota exceeded and stop creating more producer.

Modifications

In BacklogQuota add time based backlog, in BacklogQuotaManager add dropBacklogForTimeLimit to drop message when time based backlog quota exceeded.
Add isTimeBacklogExceeded in PersistentTopic to check whether time based backlog quota has exceeded for given topic.

Verifying this change

This change added tests and can be verified as follows:

  • Added unit test to verify time based backlog is applied properly, including drop message and resume normal production when backlog is cleared.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no
  • The rest endpoints: no
  • The admin cli options: no
  • Anything that affects deployment: no

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@MarvinCai
Copy link
Contributor Author

@codelipenghui @flowchartsman Please take a look.

/**
* @return determine if backlog quota enforcement needs to be done for topic based on time limit
*/
public boolean isTimeBacklogExceeded() {
Copy link
Contributor

Choose a reason for hiding this comment

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

A more efficient way to achieve this is based on the Ledger metadata, we can evaluated a time based on the Ledger create time, Ledger create time(next ledger create time) and the max entry Id of the ledger. So that we don't need to read an entry. Of course this will affect the accuracy of the limit, but the way to read the entry every time will make the bookkeeper's burden heavier in a large number of topic cluster

Copy link
Contributor Author

@MarvinCai MarvinCai Apr 1, 2021

Choose a reason for hiding this comment

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

@codelipenghui Yes, I agree, reading first entry in backlog of slowest cursor will mostly causing read from BK disk which could affect overall performance, but using metadata could also affect accuracy as you mentioned, how about we have both and make it configurable so user can make their own decision? We can have the metadata one as default.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MarvinCai LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*
* @return quota limit in bytes
*/
public long getLimit() {
return limit;
public long getLimitSize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This object is serialized, changing the name is a breaking change.
Are we handling compatibility with old configurations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I actually missed that. Added compatibility conversion and a unit test to make sure it works.

@sijie sijie added this to the 2.8.0 milestone Apr 1, 2021
@MarvinCai
Copy link
Contributor Author

/pulsarbot run-failure-checks

@MarvinCai
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@MarvinCai
Copy link
Contributor Author

/pulsarbot run-failure-checks

@sijie
Copy link
Member

sijie commented Apr 20, 2021

@MarvinCai Can you resolve the conflict?

@MarvinCai
Copy link
Contributor Author

@sijie Merged latest mainline

@Anonymitaet Anonymitaet added the doc-complete Your PR changes impact docs and the related docs have been already added. label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-complete Your PR changes impact docs and the related docs have been already added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants