Easy · 8 steps · ~30 min
Protect a public API from a traffic surge
Absorb a viral spike at the edge so your quotas hold, and throttle the right clients.
A public API gets featured on a popular site and traffic jumps twentyfold. Its backend is API Gateway, Lambda and DynamoDB, each with quotas. You will keep the backend inside its limits with an edge cache, and learn how throttling signals overload to clients.
Same problem as Public developer APIsLaunch-day pagesTicket drops
This lab uses real AWS services. Limits are AWS's documented default quotas; figures AWS does not publish are marked as assumptions on each component. See every source and assumption.
How it works
- API Gateway uses a token bucket: once request submissions exceed the steady-state rate and burst limits, clients receive HTTP 429 Too Many Requests and should retry with backoff.
- Throttling can be set lower than the account limit per stage, per method, or per client through a usage plan. AWS describes these as best-effort targets, not guaranteed ceilings.
- CloudFront caches only GET responses. Writes and uncacheable requests always reach the origin.
- Limits come from AWS documentation (default quotas in us-east-1). Where AWS publishes no figure, such as how many requests a container or database handles, the lab states its assumption on the component.
What you'll build
- A serverless backend at 2,000 requests a second
- CloudFront in front for a 40,000 requests a second surge
- What clients see when the throttle is exceeded
- How to limit one noisy client without limiting everyone
- A write-heavy surge
- An empty edge cache
- What CloudFront may cache
- Throttling per stage or method
Steps
- 1Serve 2,000 requests/s
- 2Survive a 40,000 requests/s surge
- 3What does a throttled client see?
- 4One noisy client
- 5A write-heavy surge
- 6Survive an empty edge cache
- 7What may CloudFront cache?
- 8Throttle one stage, not the account