skip to content

Request Rate Limits

Rate limiting rules count requests per characteristic, such as IP or an API key header, and act past a threshold. Interviewers ask what to key a limit on and what NAT does to it.

on this pageshow

explore

questions

5

In Cloudflare, what does a rate limiting rule count, and what happens to a client that goes over its threshold?

level: juniorimportance: must knowfreq 62%

answer

  1. one counter per characteristic value
  2. requests per period is the threshold
  3. the action lasts for a duration
  4. Block defaults to 429
  5. counted in each data center

basics

~20 s

A Cloudflare rate limiting rule counts matching requests, one counter per value of its characteristics such as the client IP. Once a counter passes requests per period, the action, such as Block with status 429, applies for the configured duration.

solid answer

~50 s

A rate limiting rule has an **expression** (which requests it watches, for example `http.request.uri.path eq "/api/login"`), **characteristics** (what each counter is keyed on: IP on every plan, more on higher plans), a threshold of **requests** per **period** in seconds, an **action** (Block, Managed Challenge, Non-Interactive Challenge, Interactive Challenge, or Log on Enterprise) and a **duration**, the mitigation timeout. When one counter goes over the threshold, that request and every later matching request with the same characteristic values get the action until the duration ends. Block returns `429` by default, or a custom 400 to 499 status and body. Counters live in each Cloudflare data center, so the limit is approximate rather than an exact global count. On current plans every rate limit is such a rule in the `http_ratelimit` phase; the older usage-billed Rate Limiting is gone.

go deeper

for a junior

Name the five parts: expression, characteristics, requests per period, action and duration. Say that Block answers 429 by default and that the action lasts for the duration.

for a middle

Explain that a counter exists per combination of characteristic values per data center, and why cf.colo.id is always one of them. Know how challenge actions throttle on non-Enterprise plans.

for a senior

Show you know the limits of precision: per-data-center counters, a few seconds of counting delay, and fail-open under overload. Say what that means for thresholds on globally spread traffic.

for a principal

Frame the rule as abuse control rather than a quota meter, and decide which limits belong at the edge and which belong in the application's own accounting.

## What a rate limiting rule does A **rate limiting rule** is a rule in Cloudflare's Ruleset Engine that lives in the `http_ratelimit` phase, which runs after WAF custom rules and before the WAF managed rulesets. An ordinary rule acts on every request it matches. A rate limiting rule instead keeps **counters** and acts only once a counter passes a threshold. Since the previous, usage-billed Rate Limiting product was retired, every zone-level rate limit is one of these rules, created under **Security rules** in the dashboard or through the Rulesets API. ## The parts of a rule | Dashboard name | API field | What it controls | |---|---|---| | When incoming requests match | `expression` | Which requests the rule watches and acts on | | With the same characteristics | `ratelimit.characteristics` | What each counter is keyed on, such as `ip.src` | | Requests and Period | `requests_per_period`, `period` | The threshold: how many matching requests in how many seconds | | Then take action | `action` | `block`, `managed_challenge`, `js_challenge`, `challenge` or `log` | | For duration | `mitigation_timeout` | How long the action keeps applying once the threshold is crossed | Two optional parameters refine this. **Increment counter when** (`counting_expression`) decides which requests add to the counter when that should differ from the matching expression. **Also apply rate limiting to cached assets** decides whether requests answered from cache count too; turning it off (the API's `requests_to_origin: true`) counts only requests that go to the origin. ## Walking one request through a rule 1. A request reaches a Cloudflare data center and is tested against the rule's expression. If it does not match, the rule ignores it. 2. Cloudflare builds the counter key from the request's values for each characteristic, for example its source IP, plus the data center ID `cf.colo.id`. Every rule carries `cf.colo.id`: the dashboard adds it silently, and an API request must list it. 3. The counter for that key goes up by one. 4. While the count stays within **Requests** for the **Period**, the request continues to later rules. 5. Once the count goes over, the action applies to that request and, by default, to every later matching request with the same characteristic values until the **duration** ends, whatever the rate during that time. Two clients with different values for any characteristic never share a counter. A rule keyed on IP and an `x-api-key` header keeps separate counts for the same key sent from two addresses. ## What the client sees - **Block** answers with `429 Too Many Requests` unless you set a custom response. The custom response takes a status code from 400 to 499, a content type (`application/json`, `text/html`, `text/xml` or `text/plain`) and a body of up to 30 KB, so an API can return JSON its clients parse. Without one, the visitor sees Cloudflare's error 1015 ("Rate limited") page. - **Managed Challenge** (the challenge Cloudflare recommends), **Non-Interactive Challenge** (`js_challenge`) and **Interactive Challenge** (`challenge`) answer with a challenge page instead of the content. - **Log**, on Enterprise plans only, records matches without acting, which is how a threshold is validated before it is enforced. On Free, Pro and Business plans a challenge action cannot have a duration. The rule **throttles** instead: a visitor who passes the challenge has their counter reset to zero and is challenged again only if they reach the threshold again. Enterprise customers can set a duration with any action, and can also throttle with Block, letting requests through whenever the rate drops back under the limit. ## Plan boundaries - **Free**: one rule, counted by IP only, a 10-second period and a 10-second duration, matching on the URI path and verified-bot status. - **Pro**: two rules, periods up to 1 minute and durations up to 1 hour. - **Business**: five rules, the **IP with NAT support** characteristic, a custom counting expression that can read the response code and headers, excluding cached assets, periods up to 10 minutes and durations up to 1 day. - **Enterprise**: up to 100 rules depending on the contract; **Advanced Rate Limiting** adds characteristics such as a header, cookie, query parameter, host, path, ASN or country, JA3 and JA4 fingerprints with Bot Management, body fields, and counting by a complexity score. ## How exact it is - Counters are kept **per data center**. Only data centers serving the same geographic location share them, and there is no network-wide counter. - Counter updates can lag a detected request by a few seconds, so some requests over the limit still reach the origin before the action starts. - Under infrastructure overload, rate limiting **fails open**: Cloudflare may skip counting and enforcement rather than block legitimate traffic, and nothing tells you it happened. So a rate limiting rule is a control against abuse and overload, not an exact meter. A quota a customer is billed by belongs in the application's own accounting.

  • Why does a visitor who solves a Managed Challenge from a rate limiting rule on a Pro zone get challenged again later?
    On Free, Pro and Business plans a challenge action cannot carry a duration, so the rule throttles. Passing the challenge resets that visitor's counter to zero. When requests with the same characteristic values reach the threshold again, Cloudflare issues a new challenge. Enterprise zones can set a duration with a challenge action, and then the action holds for that whole period.
  • Is a Cloudflare rate limiting rule's counter global across the network?
    No. Each data center keeps its own counters, shared only with data centers serving the same geographic location, which is why `cf.colo.id` is a mandatory characteristic: hidden in the dashboard, explicit in the API. A client whose traffic lands on many locations can exceed the nominal rate in aggregate, and counters update with a delay of a few seconds, so some extra requests reach the origin.

  • Past the threshold the rule only ever rejects the one request that went over.
  • Every visitor shares one counter unless the expression names an IP address.
  • Cloudflare keeps one exact global count, so exactly the limit reaches the origin.
  • A rate limiting rule's Block action returns 403 Forbidden by default.
  • Rate limits are still configured in the old usage-billed Rate Limiting product.

Assumes Cloudflare as of 2026-10-10: the usage-billed legacy Rate Limiting is retired, all rate limits are rules in the http_ratelimit phase, and the plan limits quoted are the current ones.

open as a page

With a Cloudflare rate limiting rule on a login endpoint, how does a custom counting expression count only failed logins, and what must it repeat?

level: middleimportance: must knowfreq 55%

basics

~20 s

Set Increment counter when to an expression that tests the response, such as http.response.code in {401 403}, so only failed logins add to the counter. It replaces rather than extends the matching expression, so repeat the login path and method in it.

open as a page

In Cloudflare Workers, how does the rate limiting binding enforce a per-user limit, and how do its periods and counters differ from a rate limiting rule's?

level: middleimportance: should knowfreq 32%

basics

~20 s

A ratelimits binding sets a namespace_id, a limit and a 10 or 60 second period; the Worker calls limit({ key }) with, say, the account ID and answers with its own 429 when success is false. Counters are per location and approximate.

open as a page

After a Cloudflare rate limiting rule keyed on IP went live on a mobile app's login API, thousands of users on one carrier got blocked; why, and how do you fix it?

level: seniorimportance: should knowfreq 48%

basics

~20 s

Carrier-grade NAT puts thousands of phones behind one public IP, so an IP-keyed counter adds all their logins together and can block them all. Count only failed logins, key on IP with NAT support or an identifier, and block with a JSON 429.

open as a page

As the lead for a public API on Cloudflare whose clients send an API key header, some from shared egress IPs, how do you decide what its rate limits are keyed on?

level: principalimportance: should knowfreq 36%

basics

~20 s

Layer the limits: a high per-IP ceiling that shared egress addresses can live with, a per-customer limit keyed on a validated key or claim, and a failed-authentication limit. Plan, precision and who owns the thresholds decide which layer holds which key.

open as a page