Design API rate limiting with token buckets, layered identities, endpoint costs, distributed-state tradeoffs, and measurable protection of legitimate traffic.
After identifying high-volume client addresses in API logs, design rate limiting to protect the API during a denial-of-service incident. Explain the enforcement point, identity, algorithm, and failure behavior.
### Constraints & Assumptions
The source asks how to rate limit after a log-analysis task. Request volume alone does not establish abuse, and an IP can represent many legitimate clients. No fixed traffic scale or limit is specified.
### Clarifying Questions
Which endpoints and resources are saturated? Can clients authenticate? Are bursts legitimate? What limits can be enforced at the edge versus inside the service? What should happen if the shared limiter is unavailable?
### What a Strong Answer Covers
Layered limits, appropriate keys, burst handling, distributed-state tradeoffs, clear responses, and monitoring of both attack reduction and legitimate-user impact.
### Follow-up Questions
How do you handle clients behind NAT, distributed attacks, expensive endpoints, and an attacker rotating IPs? When would an approximate local limit be preferable to a globally exact counter?
Overview: Design API rate limiting with token buckets, layered identities, endpoint costs, distributed-state tradeoffs, and measurable protection of legitimate traffic.
After identifying high-volume client addresses in API logs, design rate limiting to protect the API during a denial-of-service incident. Explain the enforcement point, identity, algorithm, and failure behavior.
Constraints & Assumptions
The source asks how to rate limit after a log-analysis task. Request volume alone does not establish abuse, and an IP can represent many legitimate clients. No fixed traffic scale or limit is specified.
Clarifying Questions Guidance
Which endpoints and resources are saturated? Can clients authenticate? Are bursts legitimate? What limits can be enforced at the edge versus inside the service? What should happen if the shared limiter is unavailable?
What a Strong Answer Covers Guidance
Layered limits, appropriate keys, burst handling, distributed-state tradeoffs, clear responses, and monitoring of both attack reduction and legitimate-user impact.
Follow-up Questions Guidance
How do you handle clients behind NAT, distributed attacks, expensive endpoints, and an attacker rotating IPs? When would an approximate local limit be preferable to a globally exact counter?