-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Bug] RateLimiter lock contention when use precise publish rate limiter #21442
Comments
Hello, I am also learning pulsar recently, have you found a solution to this problem? |
Sorry for late reply. The current publish rate limiting is based on setting the Of course, we can also optimize the implementation of |
There is some related discuss in mail list: |
Sorry, I am a beginner of pulsar, there is a problem I don't understand, can you help me solve it? The questioner has said affected other theme writing efficiency, the current theme open preciseTopicPublishRateLimiterEnable, why can affect other theme. I can't find the answer according to your answer, can you help me? |
In Pulsar internal, there are multiple topics that depend on the same thread for message writing (such as Netty's EventLoop and OrderedExecutor). If, for some reason, these threads encounter a performance bottleneck, such as the lock contention observed in this case, then even those topics not directly causing the lock contention will be affected, as long as they are also bound to these same threads. |
@Shawyeok I'm working on a non-blocking implementation that uses CAS. Please check https://github.com/lhotari/async-tokenbucket for the PoC and performance test. In addition, I'll be fixing the issue in handling the way how autoread is toggled. (WIP at https://github.com/lhotari/pulsar/blob/lh-rate-limiter-improvement/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ThrottleTracker.java ) |
@1625567290 Just curious to learn about your motivation to start learning Pulsar here. This might not be the easiest way to learn Pulsar. :) |
@lhotari Cool! I will study and verify your solution as soon as possible after my vacation, which may be a few days. |
Sounds good. Please check the blog post https://codingthestreams.com/pulsar/2023/11/22/pulsar-slos-and-rate-limiting.html for the full context. |
Search before asking
After enabled the
![image](https://private-user-images.githubusercontent.com/5058708/280208140-3dd86f3a-a2e5-4da8-9f59-9864d27608f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5MDE4MDQsIm5iZiI6MTcxODkwMTUwNCwicGF0aCI6Ii81MDU4NzA4LzI4MDIwODE0MC0zZGQ4NmYzYS1hMmU1LTRkYTgtOWY1OS05ODY0ZDI3NjA4ZjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjBUMTYzODI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODA4ZTRiNzVlODhlY2JmZDdlNzViZDBjODI5YjM2ZmZmMTMzZjljODA0ZTJhNDYyNjg0N2Q2NDJhOGI4NzI5NiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.3ve6Fi61giwPdarseB-FRfnJIIHykrfe8Yo88kIVHQ0)
preciseTopicPublishRateLimiterEnable
configuration inbroker.conf
, if one topic on the broker exceeds the publish rate limit (for example, 1MB/s), it will cause lock contention, leading to an increase in the 99th percentile write latency for other topics that have not reached the rate limit.The profile shows that there is lock content inside the method
![image](https://private-user-images.githubusercontent.com/5058708/277953123-4d2f69ab-f827-448c-92f3-5c69f7029d0b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5MDE4MDQsIm5iZiI6MTcxODkwMTUwNCwicGF0aCI6Ii81MDU4NzA4LzI3Nzk1MzEyMy00ZDJmNjlhYi1mODI3LTQ0OGMtOTJmMy01YzY5ZjcwMjlkMGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjBUMTYzODI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmRjYWNlMjdmNThlNmVhNjQxNjU1YzI0MWJlNzQ5ZTg1Njk5MTExNWJhM2UyYWYwMzRjZGJmOTdjYWRiNjA4MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.8V3d_JwSRSN-ZptN1ii0_Z0wu9VXRYuhWYtIaNztBP8)
org.apache.pulsar.broker.service.PrecisPublishLimiter#tryAcquire
.pulsar-3.0.1.lock.profile.008.html.zip
Minimal reproduce step
Noticed in a fork of
2.8.1
, reproduced in3.0.1
on Linux CentOS 7.93.10.0-1160.99.1.el7.x86_64
What did you expect to see?
One topic exceeds publish rate limit should not effect other topics write latency.
What did you see instead?
Another topic write latency also increased.
Anything else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: