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

api: adds hits_addend specifier to RateLimitRule #4957

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Dec 20, 2024

What type of PR is this?

This adds a new API into rate limit API.

What this PR does / why we need it:

This is for #4756. Basically, this adds the API to specify the hits_addend for the rate limit rule.
Especially, configuring the hits_addend in the response_path allows us to "reduce" the counter
based on the response content that affects the subsequent requests. This will enable the "token"
based request limits that are required fro AI gateway.

This is based on the Envoy's brand new features called apply_on_stream_done
and per-descriptor level hits_addend configuration introduced in

Which issue(s) this PR fixes:
#4756

Release Notes: No (until the implementation is done)

@mathetake mathetake requested a review from a team as a code owner December 20, 2024 06:42
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.71%. Comparing base (24a50b4) to head (d1b3de3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4957   +/-   ##
=======================================
  Coverage   66.71%   66.71%           
=======================================
  Files         209      209           
  Lines       32052    32052           
=======================================
  Hits        21384    21384           
- Misses       9388     9390    +2     
+ Partials     1280     1278    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mathetake
Copy link
Member Author

feel like maybe calling it "weight" instead of usage maybe be better? idk

// Number specifies the fixed usage number to reduce the rate limit counters.
//
// +optional
// +notImplementedHide
Copy link
Member Author

Choose a reason for hiding this comment

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

// https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto.html#config-route-v3-ratelimit-hitsaddend
//
// +optional
// +notImplementedHide
Copy link
Member Author

Choose a reason for hiding this comment

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

@mathetake
Copy link
Member Author

will add the cel validation this afternoon (in japan)

@mathetake
Copy link
Member Author

maybe simply Usage->HitAddends would be consistent

@mathetake mathetake changed the title api: usage based rate limit API support api: adds hits_addend specifier to global rate limit API Dec 23, 2024
@mathetake mathetake changed the title api: adds hits_addend specifier to global rate limit API api: adds hits_addend specifier to RateLimitRule Dec 23, 2024
@mathetake
Copy link
Member Author

@zirain @zhaohuabing ptal - I removed the implementation-hide as envoyproxy/ratelimit#802 got merged

@mathetake
Copy link
Member Author

i will do the implementation in a subsequent PR

@zhaohuabing
Copy link
Member

zhaohuabing commented Dec 27, 2024

@zirain @zhaohuabing ptal - I removed the implementation-hide as envoyproxy/ratelimit#802 got merged

@mathetake the implementation comment is used to hide the unimplemented EG API in the EG docs, we normally hide the API at the API PR and unhide it at the implementation PR.

zhaohuabing
zhaohuabing previously approved these changes Dec 27, 2024
Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM thanks!
Prefer to hide the API in the docs as it's not implemented yet.

@mathetake
Copy link
Member Author

ah ok - will do

@mathetake
Copy link
Member Author

@zhaohuabing hid the APIs!

Copy link
Member

@zirain zirain left a comment

Choose a reason for hiding this comment

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

LGTM, hold for a while as @arkodg may want to take a look.

Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM defer to @arkodg

@mathetake
Copy link
Member Author

👍

Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
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.

4 participants