domains / families / devops / upstash-ratelimit
upstash-ratelimit
authentic
Add rate limiting to API routes, middleware, and edge functions with @upstash/ratelimit: sliding window, fixed window, and token bucket backed by Upstash Redis.
When to use
- Use when the user needs to limit requests per IP, user, API key, or tenant
- Use when protecting login, signup, form, webhook, or LLM endpoints from
- Use when choosing between fixed window, sliding window, and token bucket.
- Do not use for client-side retry/backoff against a third-party API's limits;
- Do not use for a single long-running process with no shared state; an
When not to use
- Requires an Upstash Redis database; it does not work with other Redis
- Each `limit()` call is at least one HTTP round trip to Redis, so it adds
- Sliding window is an approximation that assumes an even spread of requests
- `MultiRegionRatelimit` trades strict accuracy for lower latency and does
- If Redis is unreachable, the default `timeout` (5 s) lets requests through
- This skill does not replace environment-specific validation, testing, or
Skill page
Source