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:
-
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.
-
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!