Course contentsShow
← Cloud and Infrastructure
Lesson 2540 of 2,98954. Serverless ArchitecturesFree lesson

Serverless API Rate Limiting and Throttling

Configure usage plans, throttling limits, and burst capacity to protect serverless APIs from overload.

Serverless API Rate Limiting and Throttling

You'll learn how to configure usage plans, throttling limits, and burst capacity to protect your serverless APIs from overload and ensure fair resource distribution.

What Is Rate Limiting and Throttling?

When you expose serverless APIs (like those behind API Gateway), you need to control how many requests clients can make. Without limits, a single user could overwhelm your backend functions, spike your costs, or degrade service for everyone else.

Rate limiting sets boundaries on requests per time period (e.g., 1,000 requests/day per API key). Throttling controls the request flow rate (e.g., 100 requests/second maximum). Think of rate limiting as a daily budget and throttling as how fast you can spend it.

Core Components

Usage Plans

Usage plans bundle throttling and quota limits, then associate them with API keys. You define:

  • Throttle rate: steady-state requests per second allowed
  • Burst capacity: temporary spike allowance (like a token bucket)
  • Quota: total requests allowed per day/week/month

Throttling Limits

Set at multiple levels:

  • Account-level: default AWS regional limits
  • API-level: applies to all requests on that API
  • Stage-level: different limits for dev vs production
  • Method-level: stricter limits on expensive operations

Burst Capacity

Handles traffic spikes by allowing temporary request surges beyond the steady rate. Once the burst "bucket" empties, requests are throttled back to the steady rate or rejected with HTTP 429 (Too Many Requests).

Key Takeaway: Serverless API rate limiting and throttling use usage plans with configurable throttle rates, burst capacity, and quotas to prevent overload, control costs, and ensure fair API access—protecting both your backend functions and legitimate users.