[POC] Replace custom token bucket with Quarkus Bucket4J extension#3506
Closed
adutra wants to merge 1 commit intoapache:mainfrom
Closed
[POC] Replace custom token bucket with Quarkus Bucket4J extension#3506adutra wants to merge 1 commit intoapache:mainfrom
adutra wants to merge 1 commit intoapache:mainfrom
Conversation
This change replaces the custom rate limiter implementation with the Quarkus Bucket4J extension, which provides a more robust and well-tested rate limiting solution. The `RateLimiter` interface is preserved (since it might be an "extension point"), and the default implementation (`RealmTokenBucketRateLimiter`) now delegates to Bucket4J via a `@RateLimited` annotated method with per-realm segmentation. Key changes: - Add quarkus-bucket4j dependency to gradle/libs.versions.toml - Create `RealmIdentityResolver` for per-realm rate limit segmentation - Rewrite `RealmTokenBucketRateLimiter` to use Bucket4J via self-injection - Add 'enabled' flag to `RateLimiterFilterConfiguration` - Update configuration to use Bucket4J properties: - `quarkus.rate-limiter.buckets.polaris.limits[0].permitted-uses` - `quarkus.rate-limiter.buckets.polaris.limits[0].period` - Update Helm chart with simplified configuration
625776f to
e087219
Compare
Member
|
I think it's worth to investigate this approach as well, either in addition to or a replacement of #3507, as it would work for a horizontally-scaled Polaris instance. |
Contributor
Author
Yes, I think this approach only makes sense if/when there is desire for a distributed token bucket. |
Member
Are you saying that we should see how users want to implement rate-limiting in the wild? |
Contributor
Author
|
Closing the PoC for now as we went with Guava's RateLimiter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change replaces the custom rate limiter implementation with the Quarkus Bucket4J extension, which provides a more robust and well-tested rate limiting solution.
The
RateLimiterinterface is preserved (since it might be an "extension point"), and the default implementation (RealmTokenBucketRateLimiter) now delegates to Bucket4J via a@RateLimitedannotated method with per-realm segmentation.Key changes:
RealmIdentityResolverfor per-realm rate limit segmentationRealmTokenBucketRateLimiterto use Bucket4J via self-injectionRateLimiterFilterConfigurationquarkus.rate-limiter.buckets.polaris.limits[0].permitted-usesquarkus.rate-limiter.buckets.polaris.limits[0].periodChecklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)