0% found this document useful (0 votes)
11 views1 page

Rate Limiting Comparison

The document explains two rate limiting approaches: the Fixed Window Algorithm, which counts requests in discrete intervals and resets at the start of each interval, and the Token Bucket Algorithm, which allows requests based on available tokens that refill at a constant rate. The Fixed Window is simpler but can lead to uneven blocking, while the Token Bucket offers better burst handling and a smoother user experience. The Fixed Window is best for small systems, whereas the Token Bucket is suited for real-time applications like banking transactions.

Uploaded by

nooknamastenook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Rate Limiting Comparison

The document explains two rate limiting approaches: the Fixed Window Algorithm, which counts requests in discrete intervals and resets at the start of each interval, and the Token Bucket Algorithm, which allows requests based on available tokens that refill at a constant rate. The Fixed Window is simpler but can lead to uneven blocking, while the Token Bucket offers better burst handling and a smoother user experience. The Fixed Window is best for small systems, whereas the Token Bucket is suited for real-time applications like banking transactions.

Uploaded by

nooknamastenook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Explain two different approaches to implementing rate limiting.

Fixed Window Algorithm: This algorithm divides time into discrete, non-
overlapping intervals, such as seconds or minutes, and counts the number of
requests within each interval. If the count exceeds a predefined limit, further
requests are denied until the next interval begins. For example, with a limit of 5
requests per second, the algorithm resets the count at the start of each second,
allowing up to 5 requests in that second.

Token Bucket Algorithm: This algorithm uses a metaphorical bucket that holds
tokens, where each token represents permission to make a request. Tokens are
added to the bucket at a constant rate (refill rate, RRR), up to a maximum capacity
(CCC). Each request consumes one token, and if no tokens are available, the request
is denied. This allows for bursts up to CCC requests if the bucket is full, while
enforcing an average rate of RRR requests per second over time.

Comparison: Fixed Window vs Token Bucket Rate Limiting


Feature Fixed Window Token Bucket
Ease of Implementation Simple and quick Slightly more complex logic
Burst Handling Not good — strict cutoff Better — allows short
bursts
User Experience Can block even genuine Smoother and user-friendly
users
Accuracy of Limit Can lead to uneven blocking More accurate and
Enforcement (spikes at window edges) consistent
Best Use Case Small systems or simple Real-time systems like
APIs banking transactions

You might also like