Page MenuHomePhabricator

Epic: Enforce API rate limits (WE5.1.3c)
Open, Needs TriagePublic

Description

Turn on rate limiting on the REST gateway, based on the setup created for T398919: Epic: API rate limiting dry run (WE5.1.3b).

The goal is to reduce the number of unidentified requests.

For the initial deployment, there will be three tiers of rate limits:

  1. very high or no limit: known clients (google bot, bing bot, etc), trusted networks (WMF, WMCS, WME), community-approved bots (TBD). See https://wikitech.wikimedia.org/wiki/CDN/Backend_api.
  2. moderate limits: authenticated requests (JWT), compliant bots (UA), and organic browser traffic (heuristic)
  3. restrictive limits: all other traffic

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
Resolveddaniel
DeclinedClement_Goubert
Resolveddaniel
Resolveddaniel
Resolveddaniel
Resolvedpmiazga
Resolvedhnowlan
Resolveddaniel
Resolveddaniel
ResolvedClement_Goubert
Resolveddaniel
Resolvedpmiazga
Resolveddaniel
Resolvedpmiazga
Resolveddaniel
Resolvedbrennen
Resolveddaniel
ResolvedClement_Goubert
Resolveddaniel
Resolveddaniel
DeclinedNone
ResolvedClement_Goubert
ResolvedJgiannelos
Resolvedtchin
InvalidNone
Resolveddaniel
Resolveddaniel
Resolveddaniel
ResolvedSLyngshede-WMF
Resolvedtaavi
Resolvedtaavi
ResolvedNone
ResolvedClement_Goubert
ResolvedClement_Goubert
DuplicateClement_Goubert
Resolveddaniel
Resolved matmarex
Resolved matmarex
Resolved matmarex
ResolvedBUG REPORT matmarex
ResolvedBUG REPORTdaniel
ResolvedBUG REPORT matmarex
ResolvedBUG REPORTdaniel
Opendaniel
Resolveddaniel
Resolveddaniel
Resolveddaniel
Resolveddaniel
ResolvedVgutierrez
ResolvedJAllemandou
Resolved DAlangi_WMF
ResolvedTgr
ResolvedJAllemandou
DuplicateNone
Resolveddaniel
Resolveddaniel
Resolveddaniel
ResolvedTgr
ResolvedTgr
Resolved matmarex
Resolved matmarex
Resolveddaniel
Resolveddaniel
Resolveddaniel
Resolveddaniel
Declineddaniel
ResolvedIKhitron
Resolvedamastilovic
Resolveddaniel
Opendaniel
Resolveddaniel
Opendaniel
Resolvedjijiki
Resolvedaaron
ResolvedBlake
ResolvedBlake
Resolveddaniel
Duplicatedaniel
Resolveddaniel
Resolveddaniel
Resolveddaniel
OpenNone
ResolvedKCVelaga_WMF
OpenNone
ResolvedClement_Goubert

Event Timeline

I haven't been able to find this in the related tasks: what does the error response you'll get look like? and is there some way to "force" an error response to test client libraries?

I haven't been able to find this in the related tasks: what does the error response you'll get look like? and is there some way to "force" an error response to test client libraries?

This will be a standard 429 with a Retry-After header, which *should* be handled correctly by most HTTP client libraries.

We also have the option to give more information via X-RateLimit headers but I don't know if that is desirable or supported by any of the other rate limiting enforcers on our stack (haproxy, varnish).

is there some way to "force" an error response to test client libraries?

Hm... That is unfortunately not easily done, since the "shadow mode" flag is in the cinfiguration of the rate limiter, it cannot be controlled per request. What we may end up doing is enabling the rate limit only on one route, for testing.

Clement_Goubert raised the priority of this task from High to Needs Triage.

Sorry for the priority noise, I misclicked while triaging.

is there some way to "force" an error response to test client libraries?

Hm... That is unfortunately not easily done, since the "shadow mode" flag is in the cinfiguration of the rate limiter, it cannot be controlled per request. What we may end up doing is enabling the rate limit only on one route, for testing.

Some way to test this in production would be really helpful to have, especially for complex scenarios like CORS requests (T418969), which are difficult to exactly replicate locally. Maybe there could be a WikimediaDebug option or something.

Create a global group like rate-limit-testers, make it emit an rlc, make the rate limit for that class 0?

A dedicated WikimediaDebug flag would be nicer for sure, but presumably harder to implement.

is there some way to "force" an error response to test client libraries?

Hm... That is unfortunately not easily done, since the "shadow mode" flag is in the cinfiguration of the rate limiter, it cannot be controlled per request. What we may end up doing is enabling the rate limit only on one route, for testing.

Some way to test this in production would be really helpful to have, especially for complex scenarios like CORS requests (T418969), which are difficult to exactly replicate locally. Maybe there could be a WikimediaDebug option or something.

I'm testing a Windows client app and associated library, and using Fiddler2 scripting to rewrite a 200 response's headers as a 429 at a rate I can control. That's something of an effort but at least I can customize the logic. Add the code to OnPeekAtResponseHeaders() if you're interested.