-
Notifications
You must be signed in to change notification settings - Fork 236
docs: dedicated page for rate limiting #3290
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
Merged
csviri
merged 5 commits into
operator-framework:main
from
csviri:rate-limiting-separation
Apr 13, 2026
+55
−47
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --- | ||
| title: Rate limiting | ||
| weight: 47 | ||
| --- | ||
|
|
||
| It is possible to rate limit reconciliation on a per-resource basis. The rate limit takes | ||
| precedence over retry/reschedule configurations: for example, even if a retry would reschedule a reconciliation | ||
| but this request would make the resource go over its rate limit, the next | ||
| reconciliation will be postponed according to the rate limiting rules. Note that the | ||
| reconciliation is never cancelled, it will just be executed as early as possible based on rate | ||
| limitations. | ||
|
|
||
| Rate limiting is by default turned **off**, since correct configuration depends on the reconciler | ||
| implementation, in particular, on how long a typical reconciliation takes. | ||
|
|
||
| Rate limiting is configured per controller, see [ControllerConfiguration](https://github.com/operator-framework/java-operator-sdk/blob/e976fb80d62f6bd0f714d78cec0a7a38d9b4a928/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ControllerConfiguration.java#L81). | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## The default LinearRateLimiter | ||
|
|
||
| We provide a generic rate limiter implementation: | ||
| [`LinearRateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/LinearRateLimiter.java). | ||
|
|
||
| To configure it, use the `@RateLimited` annotation on your `Reconciler` class. The following | ||
| configuration limits each resource to reconcile at most twice within a 3 second interval: | ||
|
|
||
| ```java | ||
| @RateLimited(maxReconciliations = 2, within = 3, unit = TimeUnit.SECONDS) | ||
| @ControllerConfiguration | ||
| public class MyReconciler implements Reconciler<MyCR> { | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| Thus, if a given resource was reconciled twice in one second, no further reconciliation for this | ||
| resource will happen before two seconds have elapsed. Note that, since rate limiting is on a | ||
| per-resource basis, other resources can still be reconciled at the same time, as long as | ||
| they stay within their own rate limits. | ||
|
|
||
| ## Custom Rate Limiter | ||
|
|
||
| You can provide your own rate limiter by implementing the | ||
| [`RateLimiter`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/rate/RateLimiter.java) | ||
| interface and setting it either through: | ||
|
|
||
| - explicit [configuration](operations/configuration.md), or | ||
| - the `rateLimiter` field of the `@ControllerConfiguration` annotation. | ||
|
|
||
| For the annotation approach, similarly to `Retry` implementations, | ||
| `RateLimiter` implementations must provide an accessible, no-arg constructor for instantiation | ||
| purposes and can further be automatically configured from your own annotation, provided that | ||
| your `RateLimiter` implementation also implements the `AnnotationConfigurable` interface, | ||
| parameterized by your custom annotation type. | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.