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
[Issue 8599] Fix DispatchRateLimiter does not take effect #8611
[Issue 8599] Fix DispatchRateLimiter does not take effect #8611
Conversation
0326f81
to
917d29e
Compare
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
917d29e
to
2b74b82
Compare
If the rate limit is 100 msg/s, and I request 10000 msg concurrently at the same time, 10000 messages will still be read, but in the next 100 seconds, none of the messages will be read. This kind of scenario is very easy to simulate, just set the |
Yes,if we start concurrently read at same time, all conumser could start there first reading and make dispatch rate far over the limiter, this could be another issue and this PR does not aim to solve this. |
/pulsarbot run-failure-checks |
2b74b82
to
21193ad
Compare
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
332ce71
to
1c6a1ef
Compare
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
1c6a1ef
to
a1e564a
Compare
/pulsarbot run-failure-checks |
@sijie @codelipenghui @rdhabalia @merlimat Please take a review at this PR. Thanks |
push this to the next release. |
a1e564a
to
2af9a90
Compare
/pulsarbot run-failure-checks |
@lhotari FYI |
2af9a90
to
d10c45b
Compare
It seems that with the changes in this PR, the RateLimiter class now has multiple algorithms that is activated with the In text books, there are algorithms such as leaky bucket and token bucket . Both algorithms have several variations and in some ways they are very similar algorithms but looking from the different point of view. It would possibly be easier to conceptualize and understand a rate limiting algorithm if common algorithm names and implementation choices mentioned in text books would be referenced in the implementation. This is more like an idea if the rate limiter classes get refactored and split as part of some other PRs. Another problem with the rate limiting are the 2 separate limits: number of messages and number of bytes. The rate limiting seems to behave in the incorrect way if those limits are both hit in some connection that is being rate limited. This is an issue in the "precise topic rate limiting" implementation. There are some comments about the challenge: #10384 (comment) . |
@lhotari Good point, Could you please open a new issue for your last comment? This PR fixes the bug of the current implementation, It's better to use a separate issue to track the new implementation of the RateLimiter. |
Fixes apache#8599 Fixes apache#4777 ### Motivation Pulsar current support topic level and subscription level dispatch rate limiter by using `DispatchRateLimiter`. When consumers connected to broker and start reading entry, broker judge whether rate limit is exceeded before reading, and increasing the permits after reading finished by call tryAcquire(). When there are multi consumers using one `DispatchRateLimiter`, these consumers could start reading together and may increasing the `acquiredPermits` far more than `permits` after reading finished. As `acquiredPermits` will reset to 0 every second, all consumers could start reading in the next second and dispatch rate limiter will take no effect in such case. ### Modifications This PR change the behaviour of `DispatchRateLimiter`, minus `permits` every second instead of reset `acquiredPermits` to 0, and the reading will stop for a while until `acquiredPermits` return to a value less than `permits` . ### Verifying this change RateLimiterTest.testDispatchRate()
Fixes #8599 Fixes #4777 Pulsar current support topic level and subscription level dispatch rate limiter by using `DispatchRateLimiter`. When consumers connected to broker and start reading entry, broker judge whether rate limit is exceeded before reading, and increasing the permits after reading finished by call tryAcquire(). When there are multi consumers using one `DispatchRateLimiter`, these consumers could start reading together and may increasing the `acquiredPermits` far more than `permits` after reading finished. As `acquiredPermits` will reset to 0 every second, all consumers could start reading in the next second and dispatch rate limiter will take no effect in such case. This PR change the behaviour of `DispatchRateLimiter`, minus `permits` every second instead of reset `acquiredPermits` to 0, and the reading will stop for a while until `acquiredPermits` return to a value less than `permits` . RateLimiterTest.testDispatchRate() (cherry picked from commit 02fc06e)
Fixes apache#8599 Fixes apache#4777 ### Motivation Pulsar current support topic level and subscription level dispatch rate limiter by using `DispatchRateLimiter`. When consumers connected to broker and start reading entry, broker judge whether rate limit is exceeded before reading, and increasing the permits after reading finished by call tryAcquire(). When there are multi consumers using one `DispatchRateLimiter`, these consumers could start reading together and may increasing the `acquiredPermits` far more than `permits` after reading finished. As `acquiredPermits` will reset to 0 every second, all consumers could start reading in the next second and dispatch rate limiter will take no effect in such case. ### Modifications This PR change the behaviour of `DispatchRateLimiter`, minus `permits` every second instead of reset `acquiredPermits` to 0, and the reading will stop for a while until `acquiredPermits` return to a value less than `permits` . ### Verifying this change RateLimiterTest.testDispatchRate()
### Motivation After PR #8611, the acquiring permits can be larger than configured msg-rate if used by subscribing. But doc was not updated in time. ### Modifications fix the outdated doc
### Motivation After PR apache#8611, the acquiring permits can be larger than configured msg-rate if used by subscribing. But doc was not updated in time. ### Modifications fix the outdated doc
Fixes #8599
Fixes #4777
Motivation
Pulsar current support topic level and subscription level dispatch rate limiter by using
DispatchRateLimiter
. When consumers connected to broker and start reading entry, broker judge whether rate limit is exceeded before reading, and increasing the permits after reading finished by call tryAcquire(). When there are multi consumers using oneDispatchRateLimiter
, these consumers could start reading together and may increasing theacquiredPermits
far more thanpermits
after reading finished. AsacquiredPermits
will reset to 0 every second, all consumers could start reading in the next second and dispatch rate limiter will take no effect in such case.Modifications
This PR change the behaviour of
DispatchRateLimiter
, minuspermits
every second instead of resetacquiredPermits
to 0, and the reading will stop for a while untilacquiredPermits
return to a value less thanpermits
.Verifying this change
RateLimiterTest.testDispatchRate()