The Fixed Window Counter rate limiting algorithm operates by dividing the time into fixed intervals and limiting the number of requests allowed within each interval.
For example, if you set a fixed window interval of 1 minute and allow 5 requests per minute, any additional requests received within that 1-minute interval will be declined or blocked based on the implementation.
Let me explain in detail with below image.
In the image, you can observe that the maximum number of requests is capped at 5 per minute. Any additional requests beyond this limit are controlled by rate limiting and will not be processed by the application.
Advantages of Fixed Window Counter
a. Easy to implement
b. Due to the simplicity, the computation overhead is very minimal.
Drawback of Fixed Window counter algorithm
Burst of traffic at the edge of windows
At the start of a fresh time window, there may be a sudden surge of requests, which could momentarily strain the system.
Another scenario is illustrated in the image below, where 4 requests are received at the 40th second of the first window (5.00.40), and 5 requests are received at the 1st second of the second window (5.01.00). In total, we are handling 9 requests within a 20-second timeframe.
System Design Questions
No comments:
Post a Comment