Hello,
I am trying to find an implement a rate limiting algorithm where the rate limit is not per
unit of time. For instance, let's say our service needs to allow 8 requests every 4 seconds. I am thinking this won't be the same as saying 2 requests per second. I tried searching online but couldn't find one which accepts a variable rate limit. I was thinking of using Token Bucket Algorithm but am confused as to how to accommodate the variable limit? Like currently, it just adds tokens based on the constant rate. I can't use any 3rd party library. Any thoughts/pointers/suggestions?
Thanks.