Prompt de conception de limiteur de débit d'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 conception de limiteur de débit d'API
Conçoit des stratégies de limitation de débit pour des APIs scalables.
Ce prompt d'IA est conçu pour vous aider à obtenir les meilleurs résultats. Suivez les instructions et personnalisez les paramètres selon vos besoins spécifiques.
Pour obtenir les meilleurs résultats, fournissez un contexte détaillé et spécifiez le format de sortie souhaité. Expérimentez avec différentes variations pour trouver celle qui convient le mieux à votre cas d'utilisation.