Fixed Window Counter Algorithm
For each time window, we allow a fixed request to go through.
For example, in this case. We only allow 3 requests for each micro second.
Pros and Cons
Pros
- Memory efficient
- Easy to implement
Cons
- Spikes in edges of the windows might cause more request to go in than allowed. For example:
- In this case, we only allow 5 requests to go in per second.
- If in the end of
2:00:00
if we have 5 requests, and then in the beginning of2:01:00
, from2:00:30
to2:01:30
we have 10 requests.
- To address this problem, we use