API Rate Limiting Cheat Sheet

Last Updated: November 21, 2025

Algorithms

Pattern Behavior
Token bucket Bursty traffic allowed up to bucket size
Leaky bucket Smooths requests to steady rate
Sliding window Per-user quota per window

Commands

redis-cli INCR api:limit:
Count requests
nginx limit_req zone=api burst=20
Configure rate limiter
return 429
Signal client to back off

Fallback

Provide `Retry-After`, cache common responses, and queue non-critical jobs.

💡 Pro Tip: Expose rate-limit headers and allow graceful degradation when throttled.
← Back to Databases & APIs | Browse all categories | View all cheat sheets