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

[OPIK-68] Add rate limit #261

Merged
merged 14 commits into from
Sep 20, 2024
Merged

[OPIK-68] Add rate limit #261

merged 14 commits into from
Sep 20, 2024

Conversation

thiagohora
Copy link
Contributor

@thiagohora thiagohora commented Sep 17, 2024

Details

Add rate limit functionality.

Added @RateLimited annotation to apply rate limit to an endpoint.

The following properties control the limit buckets (For now, only one generalEvents)

rateLimit:
    enabled: ${RATE_LIMIT_ENABLED:-false}
    generalLimit:
      limit: ${RATE_LIMIT_GENERAL_EVENTS_LIMIT:-5000}
      durationInSeconds: ${RATE_LIMIT_GENERAL_EVENTS_DURATION_IN_SEC:-1}

In the case of batch operations, an interface called RateEventContainer allows the interceptor to know the number of items in the batch.

When enabled, the rate limit is communicated via headers and status 429 (TOO_MANY_REQUESTS) when the limit is reached.

    Opik-User-Limit: general_events
    Opik-User-Remaining-Limit: 0
    Opik-User-Remaining-Limit-TTL-Millis: 300

Issues

OPIK-68

Testing

Tested locally via Minikube setup and also via Component Tests in the pipeline.

@thiagohora thiagohora marked this pull request as ready for review September 18, 2024 22:14
@thiagohora thiagohora requested a review from a team as a code owner September 18, 2024 22:14
@thiagohora thiagohora force-pushed the thiagohora/OPIK-68_add_rate_limit branch 3 times, most recently from 2e312b4 to 9e182bb Compare September 19, 2024 14:42
Nimrod007
Nimrod007 previously approved these changes Sep 19, 2024
@thiagohora thiagohora self-assigned this Sep 19, 2024
andrescrz
andrescrz previously approved these changes Sep 20, 2024
Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

In general, very well done!!! This is fine to go for the general case. But I left some comments as I believe this should have follow-up PRs in order to cover a few gaps. Also, there's one question that we need to decide and agree for the case of failed requests.

Nimrod007
Nimrod007 previously approved these changes Sep 20, 2024
@thiagohora
Copy link
Contributor Author

Sorry, I found a typo

@thiagohora thiagohora merged commit 081f0bf into main Sep 20, 2024
7 checks passed
@thiagohora thiagohora deleted the thiagohora/OPIK-68_add_rate_limit branch September 20, 2024 10:49
dsblank pushed a commit that referenced this pull request Oct 4, 2024
* [OPIK-68] Add rate limit

* Add tests

* Add batch endpoint rate limit

* Add new rate limit headers

* Address PR feedback

* Address PR feedback
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