-
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
base: main
Are you sure you want to change the base?
kafka-broker-dispatcher rate limiter #4208
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lamluongbinh The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @lamluongbinh! It looks like this is your first PR to knative-extensions/eventing-kafka-broker 🎉 |
Hi @lamluongbinh. Thanks for your PR. I'm waiting for a knative-extensions member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
triggerVReplicasAnnotationValue, ok := trigger.Annotations[triggerVReplicasAnnotation] | ||
if ok { | ||
vReplicas, err := strconv.Atoi(triggerVReplicasAnnotationValue) | ||
if err == nil { | ||
egress.VReplicas = int32(vReplicas) | ||
} | ||
} |
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.
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:
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata: ...
spec:
scale: 10
# other spec stuff here
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:
Rate Limit = MaxPollRecords × vReplicas × Number of Dispatcher Pods
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
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata: ...
spec:
maxRatePerPod: 30
Example 2: Using annotations for rate limits
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
annotations:
kafka.eventing.knative.dev/maxRatePerPod: "30"
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?
Fixes #
Proposed Changes