Hi Spandan Mishra,
In the example, we have a maximum rate limit of two requests in a minute. In other words, the log size is set to two. So the number of requests per minute can’t increase the limit 2.
Let’s break down the steps described in the slide 4:
- A new request arrives at the system’s timestamp 02:25.
- The algorithm checks the time frame or window to determine which requests are within the latest time frame and which ones are outdated. The latest time frame is defined according to the timestamp of the new request, spanning the last minute from 01:25 to 02:25.
- Any requests sent before 01:25 are considered outdated because they fall outside the latest time frame, which covers the past minute. Since the log has reached its maximum size limit, two outdated timestamps are removed from the log to make space for new requests.
- After removing the outdated timestamps, the log size becomes 2, indicating that there is space available in the log to accommodate the new request.
- Since there is now space available in the log after removing outdated entries, the new request with the timestamp 02:25 is accepted and added to the log.
I hope this clears the doubts.
Happy learning!