-
Notifications
You must be signed in to change notification settings - Fork 28
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
dev: Add Rate limits for rest endpoints #735
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
📢 Thoughts on this report? Let us know! |
@@ -73,3 +73,18 @@ | |||
CSRF_TRUSTED_ORIGINS = [ | |||
get_config("setup", "trusted_origin", default="https://*.codecov.dev") | |||
] | |||
|
|||
REST_FRAMEWORK = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont want to add rate limits to staging
❌ 57 Tests Failed:
View the top 3 failed tests by shortest run timeprofiling.tests.test_views�test_creating_profiling_commit_already_exist profiling.tests.test_views�test_creating_profiling_commit_does_not_exist upload.tests.views.test_commits�test_commit_github_oidc_auth To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
Codecov ReportAttention: Patch coverage is
Changes have been made to critical files, which contain lines commonly executed in production. Learn more ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #735 +/- ##
================================================
+ Coverage 96.05000 96.08000 +0.03000
================================================
Files 814 815 +1
Lines 18489 18754 +265
================================================
+ Hits 17760 18020 +260
- Misses 729 734 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This reverts commit 43f1a58.
Purpose/Motivation
This PR aims to update our DRF (Django Rest Framework) configuration to also include a basic ratelimiter. Rudimentarily, it uses the default "anon" and "user" throttle classes that DRF gives us out the box and sets the request rate to 30/min for anon requests and 90 for user requests. Additionally, we have a "sustained" rate limit of 1000/day for anons and 2000/day for users
Testing it locally with 10x reduction in the above values and it seems to work pretty well. We should be able to track all the instances of 429s coming to sentry and create charts / graphs as well. Maybe even alerts too if there's a way to capture the IP.
It should also be noted that the rate limit currently is shared across ALL endpoints. so the user gets a "90 limit" each minute shared between every call of account-details / users / etc.
Related notion doc
Reference
Hooked up with Gazebo
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.