CLOUD CONCEPT

Rate Limiting

Rate limiting controls how many requests or operations a client or workload can perform within a defined period.

Cloud Concepts Hub →

What is Rate Limiting

Rate limiting protects shared resources by restricting traffic according to a measured request rate, an allowed burst, and an enforcement policy. At the cloud edge, it helps reduce application-layer abuse and backend overload, but effective policies must distinguish legitimate traffic spikes from harmful behavior.

Rate limiting establishes a traffic budget and defines what happens when that budget is exceeded. A policy might permit each authenticated customer to make 100 requests per second, or restrict repeated requests to a login endpoint from the same source. The essential decisions are what traffic to count, how to group it, which time interval or algorithm to use, and whether excess traffic should be rejected, delayed, or challenged. It is different from a concurrency limit, which restricts the number of operations executing simultaneously rather than the number arriving over time.

Common implementations use fixed windows, sliding windows, or token buckets. Fixed windows are straightforward but can permit concentrated bursts across adjacent window boundaries. Sliding windows account for recent traffic more continuously. A token bucket replenishes permission to send requests at a configured rate while allowing accumulated tokens to support short bursts. These approaches are not interchangeable: a sustained rate of 100 requests per second does not necessarily mean that the 101st request in every calendar second will be rejected.

In cloud architectures, enforcement can occur at a content delivery network, web application firewall, API gateway, reverse proxy, or application. Edge enforcement rejects unwanted traffic before it consumes origin capacity, while application enforcement can use authenticated customer identities and business-specific costs. For example, a search endpoint might need a lower allowance than a cached product page because each search performs expensive database work. Layered limits can combine an overall capacity ceiling with narrower limits for customers or sensitive routes.

The aggregation key determines who shares a limit. Per-IP limits are useful for basic abuse control, but users behind corporate proxies or carrier-grade NAT can share one address and inadvertently share one budget. Conversely, attackers can rotate addresses to evade per-IP enforcement. API keys, authenticated identities, session attributes, or supported combinations of request characteristics can improve grouping. Client-supplied headers are not automatically trustworthy. When using a forwarded client-IP header, ensure that trusted proxies establish its value and that untrusted clients cannot bypass those proxies or forge the identity used for enforcement.

AWS WAF implements this idea through rate-based rules. A rule can aggregate matching requests by IP address or supported custom keys and apply an action when an aggregation instance exceeds its configured threshold over the evaluation window. A scope-down statement can restrict counting to a login path, selected countries, or another request subset. Geographic matching and supported TLS fingerprint matching can refine a policy, but neither proves a client's identity or malicious intent. Geography alone is not rate limiting: a geographic block denies matching traffic regardless of its frequency.

Rate-based security controls should not be treated as exact accounting systems. AWS WAF estimates request rates and can take time to detect a threshold crossing or stop applying an action after traffic subsides. Similarly, gateway throttling can be best effort rather than a strict contractual ceiling. Use transactional application-side accounting when a business requirement demands an exact purchase, spending, or usage limit. Rate limiting also does not replace authentication, authorization, bot defenses, or volumetric DDoS protection.

Roll out policies using observed traffic and nonblocking evaluation where supported. For example, measure legitimate login bursts before enforcing a per-IP threshold, and inspect whether shared networks dominate matches. Review rule priority because an earlier terminating allow rule can prevent a later rate-based rule from evaluating traffic. Monitor matched requests, enforcement actions, origin load, and customer failures. For API rejection, HTTP 429 and appropriate retry guidance help clients respond; exponential backoff with jitter reduces synchronized retries. Finally, prevent direct origin access from bypassing edge controls, and tune limits as application capacity and traffic patterns change.

Key aspects of Rate Limiting

Effective rate limiting combines a clear traffic budget, trustworthy aggregation, appropriate enforcement, and continuous tuning across edge and application layers.

Explicit traffic budget

Define the allowed rate, measurement window or algorithm, and burst behavior. Specify whether the policy protects backend capacity, limits abuse, or allocates fair access, because these goals can require different thresholds.

Identity and aggregation

Choose whether requests share a budget by IP address, authenticated customer, API key, or another supported key. Account for shared addresses, rotating clients, missing key values, and spoofable headers before relying on the grouping.

Scoped edge enforcement

Apply tighter rules to expensive or abuse-prone endpoints rather than treating every request equally. Geography and client fingerprints can refine matching, but they are contextual signals rather than reliable identities.

Algorithm and enforcement precision

Fixed windows, sliding windows, and token buckets produce different burst behavior. Distributed edge controls may use approximate measurements and delayed enforcement, so they should not be assumed to provide exact quotas.

Controlled excess-traffic handling

Choose rejection, challenge, or bounded queuing according to the platform and workload. API clients should handle throttling responses with backoff and jitter rather than immediately retrying at full speed.

Observable, layered operation

Combine broad edge protection with customer-aware application limits, and prevent origin bypass. Use logs, metrics, nonblocking evaluation, and rule-priority checks to detect false positives and gaps in enforcement.

Cloud services for Rate Limiting

CloudFront places delivery and caching at the edge, while an associated AWS WAF web ACL can filter excessive request rates using scoped aggregation rules. API Gateway adds API-specific throttling before backend execution and, for REST APIs, can apply usage-plan controls to API keys. These layers protect different boundaries: edge rules address abusive request patterns, gateway throttling manages API traffic, and application logic enforces authenticated business limits. Configure trusted client identity propagation, restrict direct origin access, and monitor each layer separately because their counting methods, scopes, and enforcement timing differ.

AWS WAF image AWS WAF

Rate-based rules track request rates for configured aggregation instances and apply actions such as blocking or challenging excess traffic. Scope-down statements narrow the requests counted, and web ACLs can protect supported resources such as CloudFront distributions and Application Load Balancers.

Open AWS WAF →
Amazon API Gateway image Amazon API Gateway

API Gateway applies token-bucket throttling to protect API backends, with available throttling scopes depending on the API type. REST API usage plans can add per-API-key throttling and quotas, but these are best-effort controls rather than hard usage ceilings, and API keys do not replace authentication.

Open Amazon API Gateway →
Amazon CloudFront image Amazon CloudFront

CloudFront provides an edge entry point where an associated AWS WAF web ACL can enforce rate-based rules before requests reach the origin. Caching reduces origin demand but is not itself a configurable per-client request-rate limit.

Open Amazon CloudFront →