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

Implementation of RateLimitNetworkTrafficListener #406

Merged
merged 8 commits into from Aug 9, 2023

Conversation

trnguyencflt
Copy link
Member

@trnguyencflt trnguyencflt commented Aug 1, 2023

This PR implements a method to slowdown the reading rate from HTTP/TCP socket in Jetty. The approach is based on the fact that we can use NetworkTrafficListener to count for the reading from TCP sockets on all connections. This introduces 3 new configurations (there will be changed in cc-spec-kafka):

  1. network.traffic.rate.limit.enable: whether to enable this rate limit
  2. network.traffic.rate.limit.backend: backend of rate limiting, either guava or resilience4j
  3. network.traffic.rate.limit.bytes.per.sec: the rate to limit, default to 20MiB

Reference JIRA https://confluentinc.atlassian.net/browse/KREST-11222

@trnguyencflt trnguyencflt marked this pull request as ready for review August 7, 2023 14:22
@trnguyencflt trnguyencflt requested review from a team as code owners August 7, 2023 14:22
"network.traffic.rate.limit.backend";
protected static final String NETWORK_TRAFFIC_RATE_LIMIT_BACKEND_DOC =
"The rate-limiting backend to use. The options are 'guava', and 'resilience4j'."
+ "Default is 'guava'.";
Copy link
Member

@ehumber ehumber Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, the kafka-rest default may be guava (and good we match it), but we actually run with the config set to resliance4j, so the launch darkly setting should match that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll make the config in LD set to resilience4j

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to keeping both guava/resilience4j as 2 options? I never understood why kafka-rest gives an option.
IMO, ideally whatever the reason, would have converged to 1 option by now, no reason to have LD/config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is some historical reason I think when it first developed

Copy link
Member

@msn-tldr msn-tldr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trnguyencflt This mostly looks good, thanks for doing the change!

Most of the comments are nits, but is it possible to improve the test? see my comment above.

…d change the test to show drastic effect of rate limiting
@trnguyencflt
Copy link
Member Author

@msn-tldr I have addressed the comments, could you please have a look again?

Copy link
Member

@msn-tldr msn-tldr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left feedback on updating comments before merging.

@trnguyencflt trnguyencflt merged commit 4e3152a into master Aug 9, 2023
4 checks passed
@trnguyencflt trnguyencflt deleted the KREST-11222-rate-limiting-socket-channels branch August 9, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants