Skip to content
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

Eventing Trigger - dispatcher rate limiter #4171

Open
lamluongbinh opened this issue Nov 26, 2024 · 3 comments
Open

Eventing Trigger - dispatcher rate limiter #4171

lamluongbinh opened this issue Nov 26, 2024 · 3 comments

Comments

@lamluongbinh
Copy link

Hi Team,

I am currently working on applying a rate limiter to control the rate of messages process by a Trigger.

Based on my tests, this can be achieved by:

  1. Enabling the feature flag: dispatcher-rate-limiter: enabled.
  2. Creating a new broker with 1 partition.
  3. Adding an annotation to the Trigger to ensure it is ordered: kafka.eventing.knative.dev/delivery.order: ordered.
  4. The limit is determined by the following equation: LimitedNumber = NumberOfPartitions * 20

I would like to ask if there is another way to control the LimitedNumber.

From my reading of the code, the bucket is calculated a: link

bucket = vReplica * (MaxPollRecords or NumberOfPartitions)

Alternatively, is there a way to apply a configuration or annotation to set the limit number for a Trigger?

@lamluongbinh lamluongbinh changed the title Request for assistance about dispatcher rate limiter Trigger - dispatcher rate limiter Nov 26, 2024
@lamluongbinh lamluongbinh changed the title Trigger - dispatcher rate limiter Eventing Trigger - dispatcher rate limiter Nov 26, 2024
@pierDipi
Copy link
Member

pierDipi commented Nov 26, 2024

Hi @lamluongbinh

I would like to ask if there is another way to control the LimitedNumber.

From my reading of the code, the bucket is calculated a: link

bucket = vReplica * (MaxPollRecords or NumberOfPartitions)

Alternatively, is there a way to apply a configuration or annotation to set the limit number for a Trigger?

currently, there is not, however, I'm wondering if the way is configurable is working for you

Based on my tests, this can be achieved by:

  1. Enabling the feature flag: dispatcher-rate-limiter: enabled.
  2. Creating a new broker with 1 partition.
  3. Adding an annotation to the Trigger to ensure it is ordered: kafka.eventing.knative.dev/delivery.order: ordered.
  4. The limit is determined by the following equation: LimitedNumber = NumberOfPartitions * 20

from where did you get that 20 ? I think you should see 1 event per second in this case

@lamluongbinh
Copy link
Author

lamluongbinh commented Nov 27, 2024

Hi @pierDipi,

Thanks for your reply.

The number is showing in my test, but I'm not sure where the value of 20 comes from. Could it be the default worker pool size for Vert.x (20 threads)? Initially, I tested with 1 partition, and then increased it to 3 partitions. The behavior is as follows:

  1. With 1 partition: The rate limit is set to 20 messages per second.
  2. After increasing to 3 partitions (without sending new messages): No messages are allocated to partitions 2 and 3. As a result, the rate limit remains at 20 messages per second.
  3. When new messages are sent: They start filling partitions 2 and 3, causing the rate limit to increase to 60 messages per second as more partitions contribute to processing.
  4. Once partitions 2 and 3 are processed (and no new messages arrive): The rate limit drops back to 20 messages per second, aligning with the load on the active partitions.

image

@pierDipi
Copy link
Member

which version are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants