-
Notifications
You must be signed in to change notification settings - Fork 119
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
kafka-broker-dispatcher rate limiter #4208
Open
lamluongbinh
wants to merge
3
commits into
knative-extensions:main
Choose a base branch
from
lamluongbinh:kafka-broker-dispatcher-rate-limiter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−2
Open
Changes from all commits
Commits
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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think using this annotation is the correct direction to go for manually controlling the scale of triggers. There has been discussion about implementing the scale subresource for the triggers and then using that here to set the vreplicas for the egress.
Any thoughts @pierDipi @creydr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your reply, @Cali0707. Do we have any documentation about the scale subresource that you mentioned above? Is it k8s scale subresource?
I added the vreplicas annotation here since it’s easier to manage via annotations. Making changes directly in the CRDs would be riskier and require additional modifications.
If we don’t use annotations, I’m curious if there’s a manual way to control the vreplica/rate for each trigger. This would be especially useful since each trigger sends messages to different services, each with unique needs, SLOs, and allocated resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scale subresource is documented here: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#scale-subresource
It provides a consistent API for anything wanting to scale a resource in the k8s ecosystem. With this approach, your trigger spec would look something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Kubernetes, the scale subresource primarily facilitates scaling out physical dispatcher pods, which can enhance processing capacity and accelerate resource handling. However, simply increasing the number of pods does not directly address rate limiting. In fact, scaling out could unintentionally disrupt the rate limiting logic, as adding more pods would result in a higher overall processing rate.
The current rate limiting formula is:
Scaling pods out just make us have higher rate limit for all triggers.
Current Approach
In our current implementation, rate limits can be controlled by adjusting the number of vReplicas and dispatcher pods. To support this, I have introduced an annotation that enables dynamic rate limiting by modifying the vReplicas value.
Future Considerations
If we decide to utilize the scale subresource to improve processing speed in the future, additional logic will be required to ensure rate limits remain consistent. This could be achieved by introducing new annotations or configuration options that control rate limits independently. A potential solution would be dynamically adjusting rate limits within the trigger configuration, such as:
Example 1: Defining rate limits in the spec
Example 2: Using annotations for rate limits
Ultimately, achieving a balance between scaling and rate limiting is crucial to maintaining system performance while ensuring that processing limits are not exceeded.
Any thoughts on your end?