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
Opendaniel
DeclinedClement_Goubert
Resolveddaniel
Resolveddaniel
Resolveddaniel
Resolvedpmiazga
Resolvedhnowlan
Resolveddaniel
Resolveddaniel
ResolvedClement_Goubert
Resolveddaniel
Resolvedpmiazga
Resolveddaniel
Resolvedpmiazga
Resolveddaniel
Resolvedbrennen
Resolveddaniel
ResolvedClement_Goubert
Resolveddaniel
Resolveddaniel
DeclinedNone
OpenNone
OpenJgiannelos
StalledNone
InvalidNone
Resolveddaniel
Resolveddaniel
Resolveddaniel
OpenSLyngshede-WMF
Resolvedtaavi
Resolvedtaavi
OpenNone
ResolvedClement_Goubert
ResolvedClement_Goubert
DuplicateClement_Goubert
Resolveddaniel
Resolved matmarex
Resolved matmarex
Resolved matmarex
OpenNone
OpenNone
Resolveddaniel
Resolveddaniel
ResolvedVgutierrez
ResolvedJAllemandou
ResolvedDAlangi_WMF
ResolvedTgr
ResolvedJAllemandou
DuplicateNone
Resolveddaniel
Resolveddaniel
Resolveddaniel
OpenNone
OpenTgr
OpenTgr
Open matmarex
OpenNone
OpenNone
OpenBUG REPORTNone
OpenNone

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.