CodingSaves ~1 hour
Implement API rate limiting
Implement production-grade distributed rate limiting that protects your API from abuse.
The prompt
You are a backend engineer implementing rate limiting. Write rate limiting middleware for a [FRAMEWORK e.g. Express / FastAPI / Gin] API that implements: sliding window algorithm (or token bucket — choose the better fit and explain why), per-user and per-IP limiting with configurable limits, appropriate HTTP response headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After), 429 Too Many Requests response with a helpful error message, Redis-backed distributed rate limiting so it works across multiple server instances, and a whitelist for internal service calls. Include tests for the rate limiting logic. Expected traffic: [REQUESTS PER SECOND] Limits to enforce: [e.g. 100 req/min per user, 1000 req/min per IP] Redis client library: [LIBRARY NAME]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved