Prompt
What should I use for external API rate limiting?
Latest observation
Oct 22, 2026
OpenAI APIWeb search: off
For external API rate limiting, the best choice depends on where you want to enforce the limit:
1. At the edge / gateway
Use this if you want to protect your API before requests reach your app.
Good options:
- NGINX / Envoy
- Kong
- AWS API Gateway
- Cloudflare
- Apigee
- Azure API Management
Best for:
- Per-user / per-IP limits
- Protecting upstream services
- Centralized enforcement
2. Inside your application
Use this if the rate limit is tied to business logic, like per-customer quotas or paid plans.
Good libraries:
- Python:
slowapi,limits,django-ratelimit - Node.js:
rate-limiter-flexible,express-rate-limit - Go:
golang.org/x/time/rate - Java: Bucket4j
- .NET: built-in rate limiting middleware, or Polly for resilience patterns
Best for:
- User/account-based limits
- Plan quotas
- Fine-grained custom rules
3. Distributed rate limiting
If you have multiple app instances, use a shared backend like:
- Redis (most common)
- Memcached
- DynamoDB / PostgreSQL for simpler or lower-scale setups
Common pattern:
- App instances check/update a shared counter or token bucket in Redis
- Ensures consistent limits across servers
Practical recommendation
- Small/simple app: use an application library + Redis
- Public API / production: use an API gateway or edge proxy + Redis-backed distributed limits
- Cloud-native: use managed API gateway rate limiting if available
If you’re asking “what should I choose?”
A solid default is:
Redis-backed token bucket or sliding window rate limiting, enforced at the API gateway or in the app middleware.
If you tell me your stack (language/framework/cloud) and whether you mean outbound calls to third-party APIs or your own inbound API, I can recommend the exact tool/library.