Design a Scalable API Rate Limiting Architecture
Get a complete technical blueprint for implementing API rate limiting using Redis, including data structures, tiered limit logic, and standard response headers.
Prompt
Act as a Senior Backend Architect. Design a robust API rate limiting and throttling system. Before providing the design, ask me these three questions: 1. What is your primary programming language and web framework? 2. What is the expected request volume in requests per second during peak hours? 3. Do you have existing infrastructure like Redis or Nginx already in place? After I answer, provide the architecture following these rules: 1. Use the Token Bucket algorithm for throttling. 2. Define specific Redis data structures for tracking tokens and timestamps. 3. Include standardized HTTP response headers for rate limit status (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and Retry-After). 4. Create distinct tiers for authenticated users and anonymous visitors. Output format: 1. Architecture Overview (a short paragraph). 2. Redis Data Structure Schema (key naming conventions and types). 3. Logic Flow (step-by-step processing for an incoming request). 4. Response Header Specification (table with name, description, and purpose). 5. Tiered Limit Strategy (table comparing anonymous vs authenticated users).Example output
Tips and common edits
Why this works
- Enforces a specific, industry-standard algorithm (Token Bucket) for consistency.
- Forces the use of Lua scripts to ensure atomicity in high-concurrency Redis environments.
- Structures output into clear, actionable sections: schema, logic, and headers.
Use this prompt when you need to architect a production-grade rate limiting system. It works best in ChatGPT, Claude, or Gemini. Answer the three questions clearly after pasting the prompt.
Common edits
- Adjust the tiered limits table to match your specific business requirements.
- Add a section on handling distributed denial-of-service (DDoS) scenarios if needed.
Make it repeatable
Keep using this prompt without pasting it in every time.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Design a resilient background job and retry system
Get an end-to-end background processing architecture that prevents duplicate actions, handles transient failures, and safely manages poison pills.
Design a Resilient Webhook Ingestion Endpoint
Get a complete technical design for a webhook ingestion system featuring signature verification, idempotency logic, and a robust retry strategy.
Design Cursor-Based Pagination Logic for High-Volume APIs
Get a complete implementation plan for cursor-based pagination including SQL queries, cursor encoding logic, and strategies for handling record deletions.
Design Standardized REST API Error Contracts Using RFC 7807
Generate a comprehensive, machine-readable API error schema that follows the RFC 7807 Problem Details standard for consistent, client-side error handling.
Turn a Feature Description into a REST API Endpoint Spec
Paste a feature description and get a REST API spec with a route table, request and response fields, status codes, exact validation rules, and open questions on auth and pagination.
Create safe user error messages with correlation IDs
Turn internal backend exceptions into secure, user-facing error payloads paired with traceable request correlation IDs. Use it to build clean API error contracts.