API Rate Limit Calculator

Model a token-bucket rate limiter: compute sustained rate, burst capacity, time to exhaust under load, and time to refill.

Frequently Asked Questions

What is the difference between token bucket and leaky bucket?

Token bucket allows bursts up to the bucket capacity, then enforces a sustained rate equal to the refill rate. Leaky bucket drains at a fixed rate regardless of arrival pattern, smoothing output to a steady pace and giving no burst headroom.

How big should the bucket capacity be?

Large enough to absorb normal burst patterns like page-load fan-out, mobile app startup, or retry storms, and small enough that a bad actor cannot cause harm with a single burst. A common starting point is 5-10 times the per-second refill rate.

Should limits be per user or per IP?

Per authenticated key or user is fairest and most accurate. Per IP is a useful fallback for unauthenticated traffic but fails when many users share one IP (corporate NAT, university network).

What response headers should accompany a 429?

Return X-RateLimit-Limit (the bucket capacity), X-RateLimit-Remaining (tokens left), X-RateLimit-Reset (when the bucket refills), and Retry-After (seconds until the client should retry).

How do I handle distributed rate limiting across multiple servers?

In-process token buckets don't coordinate across instances. Use a shared store like Redis with atomic increment operations, or a dedicated rate-limit service, to enforce a global limit consistently.

Important Disclaimer: Estimates for informational purposes only.

This calculator provides estimates for informational purposes only. Results are based on assumptions and may not reflect actual outcomes. Consult qualified professionals in relevant fields before making important decisions based on these results.