Replies: 1 comment
-
I agree with the HTTP 429 error code, from https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429
If we use rate limiting at nginx/route 53 we can have different limits for internal and external requests. If we use rate limiting at the API however we can give different limits to different people. One (silly) option is to add a multiplier, if your request comes from inside this ip range, your request will get a weight of X. This can be helpful for extractors. We can now add a IP address to the list where extractors run with a weight of 0, meaning these requests do not count against your rate-limit |
Beta Was this translation helpful? Give feedback.
-
The idea is to offer a way for Clowder admins to configure ratelimits for the Clowder API on managed platforms.
Base Implementation Options
Here are some options for how to go about implementing rate limits in Clowder from a high-level.
Option 1: NGINX Ratelimiting
See NGINX docs for an example of how to configure these limits
This seems like the most obvious approach, given that NGINX is already along the central entrypoint of traffic into the Clowder ecosystem.
Although NGINX configuration is notoriously complex, they do offer ratelimiting options there.
Pros:
Cons:
Option 2: Clowder API Ratelimiting
See https://github.com/sief/play-guard for a possible example of a generic plugin for handling this
This seems like a good idea if we can find a generic way to implement it.
That is, this is not a feasible approach if we need to add custom code to every API endpoint.
Pros:
Cons:
Option 3: Route53 Ratelimiting?
I looked into applying the ratelimit one level above NGINX, going to Amazon's Route53 which can be used to handle DNS resolution.
Sadly, it looks like Route53 applies its own ratelimiting, but this is not necessarily configurable or even exposed to the user.
Error-Handling Options
From Google:
There are some outliers - for example, Google Drive uses 403 Forbidden instead of 429. This could be confusing to users, as we already use 403 to indicate that the user lacks permission to perform the operation.
One example does return 429 is DockerHub, although they require you to make to an additional check to see your current limits.
Alternatively, GitHub doesn't use Reply-After but instead uses other headers embedded in the response to show how many requests the user is allowed and when the limits will reset:
My recommendation would be to stick with 429 as an error code for ratelimiting because it is commonly used to indicate that a user is ratelimited, and to differentiate it from Forbidden (aka "Permission Denied").
Other Concerns
Beta Was this translation helpful? Give feedback.
All reactions