A per-client token bucket caps each client's average rate while allowing short bursts, so one client can't use up capacity everyone shares — but set it below real traffic and you reject your own users.
300 users browse an app. Each page load fires about 20 API requests in one second, then the user reads for ten — about 3 requests per second on average. A scraper sends a steady 400 per second. The limiter is on: 5 requests/s per client with a bucket of 5. All numbers are an illustrative model.
Errors — normal users
0%
Errors — scraper
0%
429s/s
0/s
p95 — normal users
0 ms
Served
0/s
Servers busy
0%
Limit the scraper, not your users
Keep normal users' errors under 0.5% while most of the scraper's requests are turned away, for 20 seconds.
300 users browse an app. Each page load fires about 20 API requests in one second, then the user reads for ten — about 3 requests per second on average. A scraper sends a steady 400 per second. The limiter is on: 5 requests/s per client with a bucket of 5. All numbers are an illustrative model.
Illustrative model: rates, queues and latency follow simple queueing rules, not a production benchmark.