Prompt de design de limitador de taxa de API
Why this prompt matters
Rate limiting protects both your API and your users' experience. A well-designed system with clear tiers and headers builds developer trust.
What we use it for
System design
Prompt
Design a rate limiting system for the described API. Include: 1) Algorithm choice with tradeoffs (token bucket, sliding window, fixed window), 2) Rate limit tiers for different user types, 3) Response headers (X-RateLimit-*), 4) What to do when limits are exceeded (429 response body), 5) Distributed rate limiting strategy for multiple servers, 6) Implementation pseudocode.
Result
## Rate Limiting Design
### Algorithm: Sliding Window Counter Combines the precision of sliding window with the memory efficiency of fixed window.
### Tiers | Tier | Requests/min | Burst | Cost | |------|-------------|-------|------| | Free | 30 | 5 | $0 | | Pro | 300 | 50 | $29/mo | | Enterprise | 3000 | 500 | Custom |
### Response Headers ``` X-RateLimit-Limit: 300 X-RateLimit-Remaining: 287 X-RateLimit-Reset: 1710000060 Retry-After: 30 ```
### Distributed Strategy Use Redis with Lua scripts for atomic increment-and-check.
Prompt de design de limitador de taxa de API
Projeta estratégias de limitação de taxa para APIs escaláveis.
Este prompt de IA foi projetado para ajudá-lo a obter os melhores resultados. Siga as instruções e personalize os parâmetros de acordo com suas necessidades específicas.
Para obter os melhores resultados, forneça contexto detalhado e especifique o formato de saída desejado. Experimente diferentes variações para encontrar a que melhor se adapta ao seu caso de uso.