Rate limiter Algorithm | Fixed Window Counter Algorithm

How this could be a advantage in case of Fixed window counter algorithm? This also discards the requests once the counter has reached its limit.

  • As compared to token bucket-style algorithms (that discard the new requests if there aren’t enough tokens), this algorithm services the new requests.

Hi Vaibhav Arya,

You are right that the advantage you mentioned might not be an absolute advantage, but for some use-cases it is a preferable behavior. Both token-bucket style algorithms and fixed window counter algorithms discard incoming requests when their respective limits are reached. However, there’s a subtle distinction between these two strategies. Token-bucket style algorithms reject new requests and process older ones from the queue. Conversely, the fixed-window counter algorithm prioritizes new requests and discards older ones. To illustrate further, consider these two examples:

  1. Imagine an online game where we’re queuing character positions. Here, the latest position holds more importance, and discarding older positions is acceptable. For scenarios like this, the fixed-window counter algorithm is a suitable choice.

  2. Now, let’s think about sharing a recipe over WhatsApp. Each step in the recipe relies on the others, and omitting even one step could ruin the dish. Consequently, considering all the previous steps sent in various messages is crucial. In such cases, the token-bucket style algorithm, which serves older requests first, is more fitting.

While these examples may not be perfect, they clarify and help address any uncertainties.

I hope this will help.
Happy learning!