Rate Limiting

Interactive guide to rate limiting algorithms

Rate limiting controls how many requests a client can make in a given time window. It protects APIs from abuse, prevents resource exhaustion, and ensures fair usage. Explore the three most common algorithms below by clicking "Send Request" and adjusting the parameters.

These algorithms are implemented in the @gagandeep023/api-gateway npm package.

0Accepted
0Rejected
10Tokens
10
Capacity: 10
Token Bucket: The bucket starts full with 10 tokens and refills at 2 tokens/second. Each request consumes 1 token. When the bucket is empty, requests are rejected until tokens refill. This algorithm allows short bursts of traffic up to the bucket size.
Read how I built a rate limiter from scratch →