Free ops runbook · Edge rate limiting

Rate limiting at the edge: 429s that punish the wrong users

A 429 is the edge telling a client to slow down. If the bucket is keyed on IP, one office NAT, one mobile carrier or one CI runner can take the block for everyone behind it, while a distributed client stays under every per-data-center counter.

This page is free. It covers how to read a 429, why the same rule can block a whole office and miss an attack, and the response contract that stops retries from turning a rate limit into an outage.

Scope: reviewed from vendor documentation and RFCs, no live reproduction
Verified against the Cloudflare rate limiting documentation, RFC 6585 and RFC 9110 on 2026-11-12. Thresholds here are examples. The counting characteristics available depend on your plan and on whether the rule runs at the edge or in a Worker.
Read the 429

Whose 429 is it?

Edge or origin

A Cloudflare block page, a WAF challenge and your API's JSON error are three different responses. Check the body and the headers before you change a rule.

Keyed on what

IP, IP with NAT support, account, API key, path, or a custom expression. The key decides who shares a bucket; the number only decides when it empties.

Counted where

Cloudflare keeps counters per data center, not globally. A client spread across regions can stay under each local limit while the origin sees the sum.

Counted when

Counters update after a short delay, so excess requests can still reach the origin. A rate limit is burst control, not a hard quota.

Detect

Measure before you tune

Command or viewWhat it tells you
curl -sS -D - -o /dev/null https://app.internal/api/itemsStatus, cf-ray, retry-after, and whether the response is yours or the edge's.
for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code} %{time_total} ' https://app.internal/api/items; doneBurst shape: when the first 429 appears, and whether it clears.
curl -s https://api.ipify.org from the affected networkHow many users share that egress address.
curl -sS -D - https://app.internal/ | grep -i 'cf-cache-status|age'Whether the error itself is cached and being replayed.
Security → Events in the dashboardWhich rule matched, the characteristic values, and the data center.
Worker logs: request.cf.colo, cf-connecting-ipThe counter scope and the key you think you are counting.
Failure modes

Six ways a 429 hurts the wrong people

#Failure modeWhat you seeWhat to do
1Per-IP counting behind NATEveryone in one office gets 429 at the same moment; the address has thousands of users.Use IP with NAT support where available, or count on an authenticated key (session, API token) and keep a separate, higher per-IP burst limit.
2Per-data-center countersThe attack continues while one region is blocked, or an office is blocked while the attacker spreads across regions.Treat edge limits as burst control, add an origin-side global limit for the expensive path, and alert on origin load, not only on edge 429s.
3The retry storm429s turn into 503s; every client retries at the same second.Return Retry-After, add exponential backoff with jitter, cap attempts, and make your own SDKs honour the header.
4Counting the wrong requestsA normal page load of 40 assets trips a rule meant for the login endpoint.Scope by path and method, exclude static assets and health checks, and count the request that costs you something.
5Monitors and health checks eat the budgetSynthetic checks from one IP are blocked at the same time every day; the status page says the site is down.Allowlist monitor egress or give it a separate authenticated path and a distinct budget.
6A 429 with no contractClients show a generic error, users retry by hand, and support tickets say the site is broken.Return a JSON body with a machine-readable code and Retry-After; document it and make the retry advice match the bucket.
Design

Pick the bucket before the number

DecisionQuestion to answer
KeyWho should share a budget: one IP, one account, one API key, one path? Pick the unit that matches the abuse.
ThresholdWhat is the measured p99 for a legitimate client in the window? Start above it, not at a round number.
WindowA short window blocks bursts; a long one locks people out after a brief spike.
ActionBlock, managed challenge, or log only. For browsers, a challenge is often better than a hard 429; for APIs, a clear 429 is better than a challenge.
ScopeEdge only, origin only, or both. Edge limits are per data center; origin limits are global but cost you capacity.
Response

The contract that stops the storm

PartExampleWhy
Status429RFC 6585 defines 429 for too many requests; do not reuse 403 for rate limiting.
Retry hintRetry-After: 30RFC 9110 defines the header. Without it, every client guesses and they all guess zero.
Body{"error":"rate_limited","retry_after":30}A machine-readable code lets clients back off instead of showing a generic failure.
CacheCache-Control: no-storeAn error cached at the edge is an outage that outlives the traffic spike.
Verify

Test from two networks, not one

A single client backs off

Send a burst, confirm the first 429, wait for Retry-After, and confirm the next request succeeds rather than staying blocked.

A shared IP is survivable

Run the same burst from a second host behind the same NAT. If both are blocked while normal users are not, the key is wrong.

The error is not cached

Request the same URL twice after the burst and check cf-cache-status. A HIT on a 429 means the edge is replaying the failure.

The monitor still works

Confirm the synthetic check passes during the burst, or that it is excluded from the rule on purpose.

FAQ

Questions from the on-call channel

Why do users behind one office all fail at once?

They share one public address, so a per-IP rule treats them as one client. Use a NAT-aware characteristic or key the rule on an authenticated identity.

Why did the attack continue after the rule blocked one region?

Cloudflare does not share rate-limit counters across the whole network; each data center counts on its own. Add an origin-side limit for the expensive path.

Should we return 429 or 503 when the origin is overloaded?

503 means the server cannot handle the request; 429 means the client sent too many. Use 429 with Retry-After for rate limiting, and reserve 503 for real overload.

Is a challenge better than a block?

For browsers, often yes: it distinguishes a human from a script without a hard failure. For API clients, a 429 with a retry hint is clearer.

Sources

Primary sources

Going deeper on the change window?

The paid runbooks cover the surrounding failures: cache rules that hide a deploy, AI gateway rate limits, and production defaults that only bite on a real domain.

This page is free, no checkout. Paid runbooks are $9.99 each and covered by the 7-day refund policy at /runbooks/refund.