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

Add implementation of token bucket for flow-control #3106

Merged
merged 2 commits into from
Apr 25, 2023

Conversation

LearningGp
Copy link
Collaborator

Describe what this PR does / why we need it

This PR adds a simple implementation of the token bucket algorithm.
The biggest advantage of sentinel's sliding window data structure is that it can handle some extreme high concurrency scenarios, so we pay some performance costs, but in some scenarios, we need more statistical dimensions and do not care about extreme high concurrency scenarios. In these scenarios, the implementation of a lightweight token bucket algorithm may be a better choice.

Does this pull request fix one issue?

This PR is a pre-work to fix the following issues:
#263
#2231

Describe how you did it

In the implementation, the number of tokens in the token bucket is not continuously updated, it will be calculated at the time of acquisition, thereby reducing the overall performance costs.

Describe how to verify it

Run the test cases.

Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented Apr 25, 2023

CLA assistant check
All committers have signed the CLA.

@sczyh30 sczyh30 changed the title Develop token bucket Add implementation of token bucket for flow-control Apr 25, 2023
@sczyh30 sczyh30 added kind/feature Category issues or prs related to feature request. area/flow-control Issues or PRs related to flow control labels Apr 25, 2023
@sczyh30 sczyh30 added this to the v2.0.0 milestone Apr 25, 2023
Copy link
Member

@sczyh30 sczyh30 left a comment

Choose a reason for hiding this comment

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

LGTM

@sczyh30 sczyh30 merged commit 4e835d3 into alibaba:master Apr 25, 2023
@sczyh30
Copy link
Member

sczyh30 commented Apr 25, 2023

Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/flow-control Issues or PRs related to flow control kind/feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants