educative.io

Sliding Window with Counters

Hi team,

Sliding Window with counters example, the requests are counted and stored with the time stamp. How will this solve fixed window problem ? Consider the drawback of fixed window approach, sliding window with counters will also have the same problem.

please correct me if my understanding is wrong.

Thanks,
V

I think what author is trying to say for example in fixed window imagine 5 request per 10 seconds

1 second --- 1 request 
.
.
.
6 second - 2nd request 
7 second - 3rd
8 second - 4th
9 second - 5th
--
11th 

Here on 11th second it will check the the user startime of was 1 second for 1st request which is past 10 second then it will reset to 1 conter and will allow . Now in this situation what if 11th 12th 13 and till 15ht second you get request. If you see that from 6th second to 15th second you got more than 5 request.
ā€¦
In sliding window

user 1 : 1s,6s,7s,8s,9,s
when on 11th second comes it will remove from queue all request which is < current - 10sā€¦ so you will still have 6s,7s,8s,9s in queue which is >= 5 request in that case it wont allow.

1 Like

I think this is explained for sliding window, not sliding window with counters.

It seems that sliding window with counters still has the problem at the minute level. But at the hour level, it does not.

1 Like