# Rate Limiting

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

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/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.

Practice exams covering Rate Limiting: [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [SCS-C03 AWS Certified Security - Specialty](https://blowstack.com/practice-exams/aws-certified-security-specialty), [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 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.

1. **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.
2. **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.
3. **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.
4. **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.
5. **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.
6. **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](https://blowstack.com/tools/cloud-services-hub/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.
- **[Amazon API Gateway](https://blowstack.com/tools/cloud-services-hub/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.
- **[Amazon CloudFront](https://blowstack.com/tools/cloud-services-hub/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.

## Rate Limiting exam questions

Real practice exam questions on Rate Limiting, with the correct answer and its explanation.

### Question 1 (DEA-C01)

**Question:**

A company sends application events directly to an Amazon Data Firehose stream that delivers to Amazon S3. The producers generate a sustained 4,000 events per second, and each event is 1 KiB. Each event is currently submitted in a separate PutRecord request. The stream's currently applied ingestion quotas are 2,000 requests per second, 500,000 records per second, and 5 MiB per second. Monitoring shows request-rate throttling and a growing producer backlog.

The producers retain events durably until Firehose accepts them. The company must support the sustained event rate within the currently applied quotas, without adding streams or relying on capacity increases. Each event must remain a separate Firehose record. Up to 1 second of producer-side buffering is acceptable.

Which change should a data engineer make?

**Correct answer:** Use PutRecordBatch to submit up to 100 events per request, with each event supplied as a separate record. Flush pending batches within 1 second and retry failed records with exponential backoff and jitter.

**Explanation:** Batching 100 separate records reduces the required request rate to approximately 40 requests per second. The workload remains at 4,000 records per second and approximately 3.91 MiB per second, below the other applied quotas. These batches also fit within PutRecordBatch size limits. Inspecting batch results and retrying failed records handles transient failures without resubmitting records that were accepted.

### Question 2 (SAP-C03)

**Question:**

A company exposes an operational remediation service through a Regional Amazon API Gateway REST API. Authenticated automation clients call POST /restart, which invokes an AWS Lambda function to initiate a restart on a shared legacy platform. All restart requests use this endpoint. During incidents, hundreds of clients can submit requests simultaneously.

The legacy platform must never receive more than 20 restart initiations in any rolling 60-second interval, across all clients combined. Excess requests must be rejected rather than queued. The company also wants to shed excessive traffic before it reaches Lambda when possible. If the component enforcing the safety limit is unavailable, no new restarts may begin.

Which solution meets these requirements?

**Correct answer:** Configure API Gateway method-level throttling to shed excessive traffic. Before initiating each restart, have the Lambda function atomically reserve capacity in a shared, durable rolling-window limiter that permits at most 20 admissions in any 60 seconds. Reject requests when no capacity is available or the limiter cannot be accessed, and do not refund admissions when a restart's outcome is uncertain.

**Explanation:** Gateway throttling reduces unnecessary backend traffic, while the shared atomic limiter enforces the strict aggregate safety constraint despite concurrent Lambda invocations. Reserving capacity before the side effect prevents concurrent callers from oversubscribing the budget. Failing closed and retaining reservations for uncertain outcomes avoid admitting potentially unsafe additional restarts.

### Question 3 (AIP-C01)

**Question:**

A company exposes a generative AI application through an Amazon API Gateway REST API with a Lambda proxy integration. The Lambda function invokes a foundation model and already returns a standardized HTTP 429 response when inference capacity is temporarily unavailable.

A browser application at https://assistant.example.com calls the API from a different origin. Its retry logic uses bounded exponential backoff when it receives HTTP 429 with a JSON error code of CAPACITY_BUSY, and it honors the Retry-After response header. Successful responses, Lambda-generated errors, and OPTIONS preflight responses already have the required CORS configuration.

During traffic bursts, API Gateway stage throttling rejects some requests before Lambda is invoked. For these requests, browsers report CORS failures instead of exposing the retryable response. The company must retain stage throttling and make these gateway-rejected requests follow the existing browser retry contract without invoking additional backend code.

Which change meets these requirements?

**Correct answer:** Customize the REST API's THROTTLED gateway response to retain HTTP 429, return a JSON body with error code CAPACITY_BUSY, set Retry-After to a suitable retry delay, set Access-Control-Allow-Origin to https://assistant.example.com, and expose Retry-After through Access-Control-Expose-Headers.

**Explanation:** The THROTTLED gateway response controls responses generated when API Gateway throttles a request. Customizing it provides the required status, body, and headers without invoking the backend. Access-Control-Allow-Origin lets the browser access the response, and Access-Control-Expose-Headers makes Retry-After available to browser JavaScript.

### Question 4 (SAA-C03)

**Question:**

A company serves a public website through Amazon CloudFront with an Application Load Balancer as the origin. Automated clients repeatedly request the /search endpoint, generating expensive database queries and increasing origin costs. Each abusive client uses a stable public IP address. Legitimate users make fewer than 1,000 search requests in 5 minutes, but might exceed that number of requests when loading images and other website content. The company wants to temporarily block search requests from individual IP addresses with excessive search activity without blocking their access to other paths. An approximate request-rate threshold is acceptable. Which solution meets these requirements with the LEAST operational overhead?

**Correct answer:** Associate an AWS WAF web ACL with the CloudFront distribution. Add a rate-based rule that aggregates by source IP, uses a 1,000-request limit over 5 minutes, scopes down to the /search URI path, and uses the Block action.

**Explanation:** The scope-down statement ensures that only search requests contribute to the rate calculation and are subject to blocking. Aggregating by source IP gives each client a separate threshold. AWS WAF automatically applies and removes rate-based blocking as the observed rate changes, reducing expensive origin traffic without custom enforcement code.

### Question 5 (SCS-C03)

**Question:**

A company protects an API with an AWS WAF web ACL associated with an Amazon CloudFront distribution. A rate-based rule uses source-IP aggregation, a 5-minute evaluation window, and the Block action. Its scope-down statement matches POST requests to exactly /session/create. No earlier rule terminates evaluation of these requests, and the origin cannot be accessed directly.

An automation process recalculates the rule's rate limit every 30 seconds. During an incident, the process repeatedly alternates the limit between 1,800 and 2,000 requests. Several attacking IP addresses each sustain more than 20,000 matching requests per 5 minutes for 15 minutes. Legitimate IP addresses send fewer than 100 matching requests per 5 minutes. AWS WAF logs confirm that attack requests match the intended method and path, but blocking remains intermittent and most attack requests reach the origin.

Which change should a security engineer make to address the MOST likely cause?

**Correct answer:** Set the limit to 2,000 requests and suspend automated rate-limit changes. Allow tracking to stabilize, and then validate enforcement with sustained matching traffic.

**Explanation:** Changing a rate-based rule's rate limit resets its rate-limiting counts and can pause rate limiting for up to a minute. Alternating the limit every 30 seconds can repeatedly disrupt enforcement. Keeping the configuration stable allows AWS WAF to track each source IP's request rate and enforce the approximate limit.

### Question 6 (DOP-C02)

**Question:**

A SaaS company exposes an Amazon API Gateway REST API backed by AWS Lambda functions. A Lambda authorizer validates each customer's access token and identifies the customer's tenant. Customers have either a standard or premium subscription. Each tenant must receive an independent request-rate allowance based on its subscription, with a lower allowance for an expensive report method. Several tenants share corporate outbound IP addresses.

The company wants best-effort throttling to reduce backend overload, not strict billing-quota enforcement. Clients must continue sending only their existing access tokens, and they must not be able to select another tenant's throttling identity. The company wants to avoid implementing custom request counters.

Which solution meets these requirements with the LEAST operational overhead?

**Correct answer:** Create standard and premium usage plans with method-level throttling overrides for the report method. Create a separate API key for each tenant and associate it with the appropriate plan. Set the API key source to AUTHORIZER, have the authorizer return the authenticated tenant's API key as usageIdentifierKey, and require API keys on the applicable methods.

**Explanation:** With the AUTHORIZER key source, the Lambda authorizer can return usageIdentifierKey to select an API key without requiring clients to send one. A separate key for each tenant provides independent usage-plan throttling, while separate plans define subscription allowances and method-level overrides constrain the expensive method. The authorizer derives the key from the authenticated tenant rather than trusting a client-selected identity. Usage-plan throttling is best effort, which matches the requirement.

## Practice Rate Limiting in a full exam

Questions on Rate Limiting in each practice exam, with every answer option and an explanation for each:

- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 7 questions
- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 7 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 6 questions
- [SCS-C03](https://blowstack.com/practice-exams/aws-certified-security-specialty): 5 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 2 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 1 question
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 1 question

## What is Rate Limiting

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.

## Learn Rate Limiting in lessons

14 short lessons on Rate Limiting in 6 certification courses.

- DEA-C01: Backpressure vs. rate limiting (Premium), https://app.blowstack.com/lessons/backpressure-vs-rate-limiting-dea-c01
- SAP-C03: Bulkhead Pattern vs Rate Limiting (Premium), https://app.blowstack.com/lessons/bulkhead-pattern-vs-rate-limiting-sap-c03
- AIP-C01: Exponential Backoff vs. Rate Limiting (Premium), https://app.blowstack.com/lessons/exponential-backoff-vs-rate-limiting-aip-c01
- SAA-C03: Exponential Backoff vs. Rate Limiting (Premium), https://app.blowstack.com/lessons/exponential-backoff-vs-rate-limiting-saa-c03
- SCS-C03: Rate Limiting: AWS WAF rate-based policies (Premium), https://app.blowstack.com/lessons/rate-limiting-aws-waf-rate-based-policies-scs-c03
- DOP-C02: Rate Limiting: rate and burst budgets for serverless APIs (Premium), https://app.blowstack.com/lessons/rate-limiting-rate-and-burst-budgets-for-serverless-apis-dop-c02
