-
Notifications
You must be signed in to change notification settings - Fork 173
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
fix: increase the default throttle rate for enterprise users (POC) #4394
base: master
Are you sure you want to change the base?
fix: increase the default throttle rate for enterprise users (POC) #4394
Conversation
except UserThrottleRate.DoesNotExist: | ||
# If we don't have a custom user override, skip throttling if they are a privileged user | ||
if user.is_superuser or user.is_staff or is_publisher_user(user): | ||
return True | ||
|
||
# If the user is not a privileged user, increase throttling rate if they are an enterprise user | ||
if is_enterprise_user(request): | ||
self.rate = '300/hour' |
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.
[inform/context] This specific rate is still up in the air; it might need to be higher than this (e.g., 600/hour
) for enterprise users. This POC PR intends to demonstrate the approach, rather than a specific rate at the moment.
@@ -28,10 +42,15 @@ def allow_request(self, request, view): | |||
# Override this throttle's rate if applicable | |||
user_throttle = UserThrottleRate.objects.get(user=user) | |||
self.rate = user_throttle.rate | |||
self.num_requests, self.duration = self.parse_rate(self.rate) | |||
except UserThrottleRate.DoesNotExist: | |||
# If we don't have a custom user override, skip throttling if they are a privileged user | |||
if user.is_superuser or user.is_staff or is_publisher_user(user): |
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.
[inform/context] We already remove the throttling based on whether the authenticated user is a "publisher user" (aka is a member of a Django Group
). This POC is largely extending this to account for an is_enterprise_user
check as well.
4934358
to
39117c2
Compare
The
frontend-app-learner-portal-enterprise
MFE makes requests to several API endpoints withincourse-discovery
, e.g. to serve metadata about courses, programs, course recommendations, and course reviews. However, enterprise users are frequently rate limited by the default throttle rate of100/hour
(i.e., N = 2.45k requests rate limited in the past 1 week from this MFE).This PR proposes a (POC) solution for increasing the default throttle rate if the authenticated user is an enterprise user, as determined by the authenticated user's
roles
in their decoded JWT cookie.