Fixed Window Counter Algorithm

For each time window, we allow a fixed request to go through.

Pasted image 20230321171105.png

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: Pasted image 20230321171607.png
    • 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 of 2:01:00, from 2:00:30 to 2:01:30 we have 10 requests.
  • To address this problem, we use