pd
pd copied to clipboard
ratelimit: impl `BBR-like` algorithm
What problem does this PR solve?
Issue Number: ref https://github.com/tikv/pd/issues/7167 should be merged after #7239
What is changed and how does it work?
We implmented a BBR like algorithm.
-
Divide the time window into multiple time buckets of equal duration. Initialize a counter for each time bucket to keep track of the concurrency change.
-
Monitor the concurrency of requests. When request comes, increment the counter of arrival time bucket. When processed request, decrease the counter of pass time bucket.
-
Monitor the amount of pass requests. When processed request, increment the counter.
-
Record the processing duration.
-
Periodically, check the counters in each time bucket to analyze the concurrency change. If the value of any counter increases continuously over a certain threshold for a consecutive number of time buckets, it indicates the API is reaching its maximum concurrency:
- We divided the time window into multiple time buckets and counted the change of concurrency in each time bucket.
$$ \sum_{i=1}^{bucket_{size}} b_i \geq 1 $$
$$ p_i = \begin{cases} 1 &\text{if } b_i > 0\ 0 &\text{if } b_i \leq 0\ \end{cases} $$
$$ n_i = \begin{cases} 1 &\text{if } b_i < 0\ 0 &\text{if } b_i \geq 0\ \end{cases} $$
For every
$$ \forall i, \sum_{j=1}^{i} p_i \geq \sum_{j=1}^{i} n_i $$
And
$$ \sum_{i=1}^{bucket_ size/2} b_i \geq 1 $$
- According the maxinum pass request and minimum duration, calculate RDP and use it as conccurency limit.
Check List
Tests
- Unit test
Code changes
- Has the configuration change
- Has HTTP API interfaces changed (Don't forget to add the declarative for the new API)
- Has persistent data change
Side effects
- Possible performance regression
- Increased code complexity
- Breaking backward compatibility
Related changes
- PR to update
pingcap/docs
/pingcap/docs-cn
: - PR to update
pingcap/tiup
: - Need to cherry-pick to the release branch
Release note
None.
[REVIEW NOTIFICATION]
This pull request has not been approved.
To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer
in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer
in the comment to help you merge this pull request.
The full list of commands accepted by this bot can be found here.
Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.
Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all
Codecov Report
Merging #7246 (b13305c) into master (37be34e) will increase coverage by
0.01%
. Report is 97 commits behind head on master. The diff coverage is94.81%
.
:exclamation: Current head b13305c differs from pull request most recent head 348076e. Consider uploading reports for the commit 348076e to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #7246 +/- ##
==========================================
+ Coverage 73.47% 73.48% +0.01%
==========================================
Files 432 433 +1
Lines 47842 48014 +172
==========================================
+ Hits 35151 35285 +134
- Misses 9648 9672 +24
- Partials 3043 3057 +14
Flag | Coverage Δ | |
---|---|---|
unittests | 73.48% <94.81%> (+0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.