How do you rate-limit abusive clients at the edge?
IntermediateScenarioLoad Balancing, Proxies & CDN
Answer
Situation read → The limit belongs as close to the attacker as possible.
What I'd do →
- Use AWS WAF rate-based rules, for example 2000 requests per 5 minutes per IP, on CloudFront or the ALB
- Or Nginx:
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;pluslimit_req zone=api burst=20 nodelay; - Return 429 with
Retry-After - Key on API key or user when many clients share NAT IPs
- Monitor blocked counts
Why → Limits on source IP are crude for mobile carriers and offices behind NAT, so keys matter.
Interview tip → Say you always start in count mode before blocking.
More on Load Balancing, Proxies & CDN
What is the difference between a Layer 4 and a Layer 7 load balancer?BeginnerWhen do you choose an ALB and when an NLB in AWS?BeginnerForward proxy versus reverse proxy: what is the difference?BeginnerHow do health checks work on a load balancer and what makes a good one?BeginnerWhat are sticky sessions and why would you avoid them?BeginnerWhat does a CDN do and when does it help?Beginner