← Glossary

What Is Rate Limiting?

Rate limiting is a server-side policy that caps how many requests a client, key or resource may make within a time window, enforced through counters or token buckets and signalled to clients with responses such as HTTP 429.

Updated:

Rate limiting restricts how much request traffic a source may send over time. A server, gateway or edge service tracks an allowance and rejects, delays or challenges excess traffic. The policy helps preserve capacity and fairness, constrain abusive bursts and control the cost of expensive operations. It is useful for both public APIs and internal services.

This article focuses on service-enforced limits. Clients can also pace their own requests, and plan agreements can define allowances, but the service controls the actual enforcement and counting rules. HTTP gives the server a standard way to say no: the 429 Too Many Requests status, defined in RFC 6585, which that specification deliberately leaves open as to how the user is identified or how the counting is done.

Counters, Windows and Token Buckets

Every rate limiter answers one question: has this source exceeded its allowance right now? The algorithms differ in how they model the allowance over time.

Fixed window

The simplest form keeps a counter per source that resets at fixed boundaries, such as the top of each minute or hour. It is cheap and easy to explain, making it suitable for a simple published allowance. Its weakness is the boundary: a client can spend the whole allowance in the last second of one window and again in the first second of the next, allowing nearly two windows’ allowances to arrive across a short boundary interval.

Sliding window

A sliding-window log counts requests in the trailing period ending now. A sliding-window counter approximates that using weighted adjacent windows. Both reduce the fixed-boundary effect, but precision and storage costs differ; neither necessarily spreads accepted requests evenly over time.

Token bucket

A token bucket has a maximum capacity and a refill rate. Each accepted request spends tokens; an empty bucket causes rejection or waiting under the chosen policy. Capacity controls the allowed burst, while refill controls sustained throughput. Envoy’s local limiter implements this pattern. Leaky-bucket policies, such as nginx’s request limiter, can instead delay excess work toward a configured processing rate, with a bounded burst allowance.

AlgorithmState per sourceBurst behaviourTypical use
Fixed windowOne counter and a reset timeNearly two window allowances close to a boundaryHourly API quotas
Sliding windowTimestamps or two weighted countersReduces fixed-boundary burstsPer-minute limits on public endpoints
Token bucketToken count and last refillConfigurable burst up to capacityGateways and proxies
Leaky bucketQueue or equivalent accounting stateSmoothed to a constant rateTraffic shaping in web servers

Keys, Quotas and Response Signals

The counting key might be an IP address, account, API credential, session or combination of request attributes. Cloudflare’s available characteristics illustrate the range, although support varies by plan and configuration. GitHub distinguishes unauthenticated traffic by IP from authenticated usage budgets, with separate rules for applications. Per-IP limits can affect unrelated users behind a shared gateway, while per-account limits follow the authenticated identity across addresses. Neither key is sufficient for every threat or fairness goal.

Quotas can also be layered. GitHub documents primary limits expressed as requests per hour and secondary limits that cap concurrency, assign point costs to expensive write operations and bound CPU time per minute. A client can be well within its hourly quota and still be throttled for creating too much content too quickly. Cloudflare rules similarly combine a request-rate threshold with a mitigation timeout, which can keep an action active beyond the instant the threshold is exceeded.

When a request is refused, the response tells the client what happened. The standard status is 429, which RFC 6585 says should explain the condition in the body, may carry a Retry-After header, and must not be stored by caches. Retry-After gives either a number of seconds or an HTTP date, and the same header is used with 503 responses during outages. Many APIs add informational headers on every response: GitHub returns x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-used, x-ratelimit-reset and x-ratelimit-resource so a client can pace itself before being refused. Quota headers are useful for planning, but their exact scope and reset semantics must come from the service’s documentation. A positive remaining value does not promise the next request will succeed. Some servers use other statuses: nginx rejects with 503 unless configured otherwise, and GitHub returns 403 in some cases, so clients should not assume 429 is the only signal.

Rate Limits vs Concurrency Limits and Bans

Three controls are often lumped together under request throttling and behave quite differently.

A rate limit bounds how many requests arrive per unit of time. A concurrency limit bounds how many requests are in flight at the same moment, regardless of rate: nginx's limit_conn module caps simultaneous connections per key and counts only connections with a request currently being processed, and services may also impose independent limits on concurrent operations. A slow request can occupy a processing slot long after it was counted against a rate allowance; a client firing a thousand tiny requests per second can stay under a concurrency cap of ten and overwhelm a rate limiter. Services with expensive operations often need both, which the OWASP denial-of-service guidance frames as request-rate controls alongside connection, timeout and load limits.

A ban is different again. It is a decision that a source should receive no service for a period, usually because of behaviour judged abusive rather than merely frequent. A replenishing rate allowance usually becomes available with time. A ban can expire automatically or require review, depending on the policy; duration alone does not distinguish the controls. The two interact, since repeated rate-limit violations are a common trigger for escalation; GitHub states that continuing to send requests while rate limited may get an integration banned. A 403 can also mean missing authorization or another access rule, so status alone cannot establish that an account is banned.

Where Rate Limiting Is Applied

APIs use limits for fairness; login and password-reset services use them to slow abusive attempts; search and export services protect costly operations. An edge limiter can reject excess requests before application processing, while internal service limits keep one failing caller from flooding another. Placement matters because a limiter cannot recover resources already consumed before a request reaches it.

Limitations and Considerations

Rate limiting degrades service deliberately, so a badly chosen key or threshold produces false positives: students behind one campus NAT address, a mobile carrier's shared gateway or a legitimate monitoring tool can all look like a single abusive source. Distributed counters may use approximate or delayed state, allowing overshoot; strict shared accounting has its own coordination cost, and a client that honours a reset time exactly can join a synchronized surge when the window opens. Rate limits also do not stop a well-resourced attacker who spreads requests across many sources below each threshold; they raise the cost rather than removing the possibility.

Informational headers are hints, not guarantees. Advertised remaining quota can change between responses, so clients should avoid assuming that each successful response reserves capacity for another operation. Finally, the server mechanism is only half of the story. How a client detects limits, backs off and retries is a separate concern with its own patterns, and repeatedly ignoring Retry-After can trigger stronger restrictions. Retrying a write also requires attention to idempotency; waiting alone does not prevent duplicate side effects.

Frequently asked questions

Are rate limits always based on IP?

No. A service can count by IP, user account, API key, session, resource or a combination of attributes. IP-based limits are common for unauthenticated requests but are not a universal default. The chosen key affects shared-network users and how usage is combined across clients.

Does 429 always include Retry-After?

No. RFC 6585 says a 429 response may include Retry-After, not that it must. Many services omit it or expose reset timing through their own headers such as x-ratelimit-reset. Clients should handle a bare 429 by waiting a sensible interval and backing off further on repeated refusals.

How is concurrency different from request rate?

Rate counts requests per period; concurrency counts requests in flight at one moment. A slow client can hold many connections while making few requests, and a fast client can send many requests while holding few connections. Servers often enforce both, for example nginx's limit_req and limit_conn modules.

What is the difference between a rate limit and a quota?

The words overlap, but a rate limit usually describes a short-window ceiling that smooths traffic, while a quota describes a larger allowance over a day or month tied to a plan or budget. A client can be inside its monthly quota and still receive 429 responses for exceeding a per-minute rate.

Which algorithm is best for rate limiting?

It depends on the workload. Fixed windows are simple but permit bursts near their boundary. Sliding logs track recent requests precisely at a storage cost; weighted counters approximate them. Token buckets separate burst capacity from refill rate, while leaky-bucket policies can smooth processing through delay. Operational cost and acceptable bursts guide the choice.