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

enable rate limit for month and year #743

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

rpahli
Copy link
Contributor

@rpahli rpahli commented Oct 23, 2024

What type of PR is this?

adds the option to set rate limit unit to Month and Year which was introduced with envoy 1.25.

Signed-off-by: Rico Pahlisch <[email protected]>
Signed-off-by: Rico Pahlisch <[email protected]>
@rpahli rpahli force-pushed the rate-limit-month-year branch from a09cbb0 to e91afbd Compare October 23, 2024 08:29
@stefansedich
Copy link

stefansedich commented Dec 3, 2024

Thanks @rpahli just came here to open the same PR myself, good thing I looked first 😆

@collin-lee anything preventing this one from being merged? kicking off a project using the ratelimit service and monthly limits sure would be handy.

@collin-lee
Copy link

LGTM though do you expect that your service/redis would not need to be restarted for re-deployments monthly/yearly?
thoughts @arkodg?

@stefansedich
Copy link

LGTM though do you expect that your service/redis would not need to be restarted for re-deployments monthly/yearly? thoughts @arkodg?

For our use-case I had just planned to enable persistence in redis, my ultimate goal here was to add support for an additional weekly bucket, however looking at the enums over in https://github.com/tyxia/envoy/blob/b5bc27399d723806bab993895e64f9295c863016/api/envoy/service/ratelimit/v3/rls.proto#L101 it will be a breaking change to sneak WEEK in there now...

@arkodg
Copy link
Contributor

arkodg commented Dec 3, 2024

not sure I understand @collin-lee, this functionality didn't exist before, so users will need to update to a newer version with this change to leverage setting month and year limits in the ratelimit service.
did a quick scan of the code and UnitToDivider is used everywhere in the code, so this should hopefully be the only change required

@collin-lee
Copy link

collin-lee commented Dec 3, 2024

@arkodg - my question was more about the use case and @stefansedich mentioned he would persist redis values. @stefansedich - so could you do a multiple of days for weeks/months instead? (i.e 7 days for a week, 30 days for a month)?

@stefansedich
Copy link

stefansedich commented Dec 3, 2024

@arkodg - my question was more about the use case and @stefansedich mentioned he would persist redis values. @stefansedich - so could you do a multiple of days for weeks/months instead? (i.e 7 days for a week, 30 days for a month)?

That would be fine too, it just means something like #552 going in which in the end would be far more flexible and a nice addition.

I have gone ahead and added WEEK for now over in envoyproxy/envoy#37494 as I think it makes sense that it exists given we have month and year already, will open a PR here to add support once it gets merged (if it does).

@stefansedich
Copy link

@collin-lee anything remaining to get this one in? I am happy to do some additional testing if that would help.

@collin-lee
Copy link

@stefansedich - should the code return 60 * 60 * 24 * 356 use 365 instead?

@rpahli
Copy link
Contributor Author

rpahli commented Dec 6, 2024

@stefansedich - should the code return 60 * 60 * 24 * 356 use 365 instead?

the base unit is seconds so I think the code is correct

@stefansedich
Copy link

stefansedich commented Dec 6, 2024

@stefansedich - should the code return 60 * 60 * 24 * 356 use 365 instead?

@collin-lee looks right to me as the output is seconds, and replicates what was done over on the Envoy side.

case pb.RateLimitResponse_RateLimit_MONTH:
return 60 * 60 * 24 * 30
case pb.RateLimitResponse_RateLimit_YEAR:
return 60 * 60 * 24 * 356

Choose a reason for hiding this comment

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

should this be 365 instead?

@collin-lee collin-lee merged commit d36a71b into envoyproxy:main Dec 6, 2024
1 check passed
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.

5 participants