API Rate Limiter Calculator
Calculate effective RPS, burst capacity, request rejection rates, and Redis memory usage for any rate limiting strategy. Compare Token Bucket, Leaky Bucket, Fixed Window, Sliding Window Log, and Sliding Window Counter side by side.
Frequently Asked Questions
What is the difference between Token Bucket and Leaky Bucket?▼
Token Bucket accumulates tokens over time and allows short bursts when tokens are saved up — if no requests came in for 5 seconds, the bucket fills and the next burst can fire quickly. Leaky Bucket processes requests at a strictly constant output rate regardless of how they arrive, acting more like a queue with a fixed drain speed. Token Bucket is better when occasional bursts are acceptable; Leaky Bucket is better when the downstream system requires perfectly smooth traffic.
What is the boundary burst problem with Fixed Window rate limiting?▼
Fixed Window counters reset at fixed clock boundaries (e.g., every minute at :00). A client can send the full window quota in the last second of one window and immediately again in the first second of the next window — effectively sending 2× the intended rate without being throttled. Sliding Window algorithms solve this by evaluating the most recent N seconds at any point in time, with no hard resets.
When should I use Sliding Window Log vs Sliding Window Counter?▼
Sliding Window Log stores every individual request timestamp, giving you mathematically exact rate limiting. Use it when precision is critical (financial transactions, audit-sensitive APIs). Sliding Window Counter uses just two counters with a weighted approximation, giving ~±10% accuracy at window boundaries. Use it when you need high scale and low memory — it is the algorithm behind Cloudflare's rate limiting and Nginx's limit_req_zone.
How do I choose the right burst capacity for Token Bucket?▼
Burst capacity should reflect the largest legitimate traffic spike your API can absorb without degrading. A common rule: set burst capacity to 10–20% of your per-minute rate limit. For example, if your limit is 100 req/min (~1.67 req/s), a burst of 10–20 tokens lets clients make a batch of requests immediately, then they refill at the sustained rate. Set it too high and you lose protection against abuse; too low and normal clients hit 429 errors.
How much Redis memory does sliding window rate limiting use?▼
Sliding Window Counter uses approximately 74 bytes per user (two counters + timestamp + key overhead) regardless of traffic volume — very memory-efficient at any scale. Sliding Window Log scales with the number of requests per window: if your limit is 100 req/min and the window is 60 seconds, you store up to 100 timestamps (8 bytes each) plus key overhead, totaling ~850 bytes per active user. For 100,000 active users that is about 85 MB — manageable but worth planning for.
What HTTP status code and headers should rate-limited responses return?▼
Return HTTP 429 Too Many Requests. Include the following headers: Retry-After (seconds until the client can retry), X-RateLimit-Limit (total allowed requests in the window), X-RateLimit-Remaining (requests left in the current window), and X-RateLimit-Reset (Unix timestamp when the window resets). This allows well-behaved API clients to back off automatically and retry intelligently without polling your API.
Related Products
on GumroadTypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →DevToolkit Starter Kit
A ready-to-deploy developer tools website with 12 built-in tools. Astro + Preact + Tailwind. Deploy to Cloudflare Pages for free. Built-in SEO, dark mode, and ad-ready layout.
Buy on Gumroad →DevPlaybook Interview Vault
210+ real technical interview questions with model answers, asked at Google, Meta, Amazon, Microsoft, Stripe, and Shopify. Covers Frontend (55), Backend (55), System Design (50), and DSA (50). Available in English and Traditional Chinese.
Buy on Gumroad →You Might Also Need
Redis Command Tester
Test Redis commands in your browser with no install needed. Simulate SET, GET, HSET, LPUSH, EXPIRE, TTL and more with color-coded output and a built-in command reference.
Open free tool →
Redis Pipeline Builder
Build Redis command pipelines visually. Add GET, SET, HSET, LPUSH, EXPIRE and other commands, reorder them, and export as raw pipeline, redis-cli, or Node.js ioredis code.
Open free tool →
OpenAPI Validator
Paste your OpenAPI 3.x spec (YAML or JSON) to validate structure, find missing required fields, detect duplicate paths, check for missing operationIds, and get errors and warnings with path references.
Open free tool →
More Free Tools
Related Articles
API Rate Limiting: Algorithms and Implementation Guide 2026
Complete guide to API rate limiting in 2026. Token Bucket, Leaky Bucket, Sliding Window algorithms with Node.js and Redis implementations, distributed rate limiting, 429 handling, and best practices.
API Rate Limiting: Strategies, Algorithms, and Free Tools
A complete guide to API rate limiting in 2025: Fixed Window, Sliding Window, Token Bucket, and Leaky Bucket algorithms explained, with implementation in Node.js, Python, and Go, Redis-based distributed limiting, and client-side backoff strategies.
Complete HTTP Status Codes Reference for REST API Devs
The complete HTTP status codes reference for REST API developers. Every 1xx, 2xx, 3xx, 4xx, and 5xx code explained with real-world API examples and best practices.
HTTP Status Codes Explained: Complete Guide for Developers
Every HTTP status code group explained with real-world examples. Know exactly when to use 200, 201, 301, 401, 404, 429, 500, and more.
curl 深度使用手冊:API 測試從入門到進階
curl 是每位開發者必備的 CLI 工具。本文涵蓋 GET/POST/PUT/DELETE 請求、認證、header 設定、檔案上傳、除錯技巧,以及 REST API 測試的完整實戰範例。
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →