Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Rate limiting caps how many requests a client may make in a period, protecting authentication, APIs, and expensive operations from abuse and from accidental overload.

What Is Rate Limiting?
Rate limiting is the control that decides how many times a client may do something within a period. It is the difference between an attacker testing ten passwords and testing ten million, between a scraper copying a page and copying a catalogue, and between an expensive report endpoint serving its users and taking the database down. It is also one of the easiest controls to implement in a way that looks right and provides almost nothing.
| Algorithm | Behaviour | Trade-off |
|---|---|---|
| Fixed window | Counter reset on a clock boundary | Simple, but allows a double burst across the boundary |
| Sliding window | Counts the trailing period continuously | Accurate, costs more state |
| Token bucket | Tokens refill at a steady rate, bucket has a cap | Permits a controlled burst, the usual API choice |
| Leaky bucket | Requests queued and drained at a fixed rate | Smooths traffic, adds latency |
The fixed window weakness is worth understanding before choosing it. With a limit of 100 per minute, a client can send 100 at 10:00:59 and another 100 at 10:01:00, so the real short-term limit is double the stated one. Token bucket is the most common answer for public APIs because it tolerates legitimate bursts while holding the average.
Keying by IP address alone is the standard mistake. Mobile networks and corporate proxies put thousands of users behind one address, so a limit tight enough to matter blocks real people, and an attacker with a residential proxy pool defeats it regardless. Layer the keys instead: by authenticated account, by API key, by the identifier being acted on, such as the target username in a login attempt, and by network address as the coarsest and least trusted of the four.
Counting requests is also too crude for some endpoints. A GraphQL or report query may cost a thousand times more than a simple read, which is why weighted or cost-based limits exist, as discussed in GraphQL security.
X-Forwarded-For, a client supplies a new value per request. Only the address your own edge appended may be trusted./API/login, /login/, or an added query string.Return HTTP 429 with a Retry-After header so well-behaved clients back off correctly, and publish the current limit and remaining quota in response headers. For authentication specifically, the NCSC’s guidance for system owners recommends throttling attempts rather than locking accounts, precisely because lockout hands attackers a denial of service against your users. Increasing delays, combined with a CAPTCHA or step-up authentication after a threshold, keeps genuine users moving while making automation uneconomic.
Log every limit breach with the key that triggered it. A sudden rise in 429 responses is one of the clearer early indicators of an attack in progress, and without the key you cannot tell a broken integration from an adversary.
Edge enforcement at a CDN or API gateway absorbs volume before it reaches your infrastructure and is the right place for coarse protection. Application enforcement understands identity, cost, and business rules, and is the right place for anything that matters. Most environments need both, with the application treating the edge as an optimisation rather than a guarantee. Distributed deployments need shared state, usually an atomic counter in Redis, or each instance enforces its own limit and the effective total is multiplied by the number of instances. Rate limiting is a standard check in our web application security testing, where the question is rarely whether a limit exists and almost always how it is keyed.
There is no universal figure, but a few attempts per minute per account combined with a looser per-address limit suits most consumer applications. Pair it with increasing delays rather than a hard lockout, and add a challenge after a threshold. Measure your genuine users first: the limit should sit well above normal behaviour, including people who mistype passwords repeatedly.
No. Rate limiting is applied per client by your application or gateway and protects against abuse of specific functions. Distributed denial of service defence operates at the network edge, absorbing volumetric traffic from many sources before it reaches you. A rate limiter cannot help when the link itself is saturated, and a scrubbing service cannot tell that one account is testing passwords.
Usually not. Lockout turns a guessing attempt into a denial of service against your own users, since anyone who knows a username can lock it. The NCSC recommends throttling instead, with increasing delays and monitoring. Where lockout is required by policy, make it temporary and automatic rather than requiring a support call to clear.
Keep the counter in shared storage and update it atomically, typically with an increment-and-expire operation in Redis or a sliding window implemented in a short script. Without shared state, each instance enforces the limit independently and the effective limit becomes the configured value multiplied by the number of instances, which is rarely what anyone intended.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.