Skip to content

rate_limit_quota: [API] Add time unit month and year#24031

Merged
adisuissa merged 1 commit intoenvoyproxy:mainfrom
tyxia:rlqs_unit
Nov 18, 2022
Merged

rate_limit_quota: [API] Add time unit month and year#24031
adisuissa merged 1 commit intoenvoyproxy:mainfrom
tyxia:rlqs_unit

Conversation

@tyxia
Copy link
Copy Markdown
Member

@tyxia tyxia commented Nov 16, 2022

Even though for us (who introduced the rate_limit_quota feature), month and year unit are too coarse-grained unit as our traffic will be huge and we will update the Envoy config on more frequent basis, there is business need/case for monthly and yearly subscription from @renuka-fernando side.
More detailed discussion can be found #23844.

Signed-off-by: tyxia tyxia@google.com

Signed-off-by: tyxia <tyxia@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #24031 was opened by tyxia.

see: more, trace.

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #24031 was opened by tyxia.

see: more, trace.

@tyxia tyxia marked this pull request as ready for review November 17, 2022 04:48
@renuka-fernando
Copy link
Copy Markdown

I think we have to update this function too. But Month and Year do not have exact seconds, it varies from month to month, year to year, but I wish we do not want exact seconds here. @tyxia wdyt?

uint32_t XRateLimitHeaderUtils::convertRateLimitUnit(
const envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::Unit unit) {
switch (unit) {
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::SECOND:
return 1;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::MINUTE:
return 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::HOUR:
return 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::DAY:
return 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::UNKNOWN:
default:
return 0;
}
}

Comment thread api/envoy/type/v3/ratelimit_unit.proto
@tyxia
Copy link
Copy Markdown
Member Author

tyxia commented Nov 17, 2022

I think we have to update this function too. But Month and Year do not have exact seconds, it varies from month to month, year to year, but I wish we do not want exact seconds here. @tyxia wdyt?

uint32_t XRateLimitHeaderUtils::convertRateLimitUnit(
const envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::Unit unit) {
switch (unit) {
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::SECOND:
return 1;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::MINUTE:
return 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::HOUR:
return 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::DAY:
return 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::UNKNOWN:
default:
return 0;
}
}

I think there is misunderstanding here. So do you want to include the month and year to existing rate limiting feature (api/envoy/service/ratelimit/v3/rls.proto) or the new global rate limiting feature I am working on? Or both?

The PR here is for new rate limiting feature and will not use the code you mentioned above.

@renuka-fernando
Copy link
Copy Markdown

I think we have to update this function too. But Month and Year do not have exact seconds, it varies from month to month, year to year, but I wish we do not want exact seconds here. @tyxia wdyt?

uint32_t XRateLimitHeaderUtils::convertRateLimitUnit(
const envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::Unit unit) {
switch (unit) {
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::SECOND:
return 1;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::MINUTE:
return 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::HOUR:
return 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::DAY:
return 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::UNKNOWN:
default:
return 0;
}
}

I think there is misunderstanding here. So do you want to include the month and year to existing rate limiting feature (api/envoy/service/ratelimit/v3/rls.proto) or the new global rate limiting feature I am working on? Or both?

The PR here is for new rate limiting feature and will not use the code you mentioned above.

I am planning to use the existing rate limit feature (with the Envoy Rate-Limit service: https://github.com/envoyproxy/ratelimit). I think what you refer to as the new global rate limit feature is RLQS, that @markdroth mentioned in this comment envoyproxy/ratelimit#368 (review).

It is grateful if it is possible to have these units in the existing RLS feature too.
So both if possible 🙂.

@tyxia
Copy link
Copy Markdown
Member Author

tyxia commented Nov 18, 2022

I think we have to update this function too. But Month and Year do not have exact seconds, it varies from month to month, year to year, but I wish we do not want exact seconds here. @tyxia wdyt?

uint32_t XRateLimitHeaderUtils::convertRateLimitUnit(
const envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::Unit unit) {
switch (unit) {
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::SECOND:
return 1;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::MINUTE:
return 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::HOUR:
return 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::DAY:
return 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::UNKNOWN:
default:
return 0;
}
}

I think there is misunderstanding here. So do you want to include the month and year to existing rate limiting feature (api/envoy/service/ratelimit/v3/rls.proto) or the new global rate limiting feature I am working on? Or both?
The PR here is for new rate limiting feature and will not use the code you mentioned above.

I am planning to use the existing rate limit feature (with the Envoy Rate-Limit service: https://github.com/envoyproxy/ratelimit). I think what you refer to as the new global rate limit feature is RLQS, that @markdroth mentioned in this comment envoyproxy/ratelimit#368 (review).

It is grateful if it is possible to have these units in the existing RLS feature too. So both if possible 🙂.

Thanks for confirmation! The changes to existing RLS will be done in a separate PR.

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

LGTM.
/lgtm api

Comment thread api/envoy/type/v3/ratelimit_unit.proto
@adisuissa
Copy link
Copy Markdown
Contributor

As discussed offline, this should be followed by a PR to update the previously defined Unit enum.

@adisuissa adisuissa merged commit 9efcad4 into envoyproxy:main Nov 18, 2022
@tyxia tyxia deleted the rlqs_unit branch December 26, 2024 04:27
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.

3 participants