Replies: 1 comment
-
This is definitely worth looking into. I have come across this in the past and the memory efficiency with a minor trade off in accuracy with respect to the existing moving window implementation is quite significant, but I didn't have time to look into how to make it work atomically with the various backend storages at the time. For testing I would recommend updating https://github.com/alisaifee/limits/blob/master/tests/test_strategy.py & https://github.com/alisaifee/limits/blob/master/tests/aio/test_strategy.py (copy paste a few of the fixed window tests) - and that would allow you to test across the different storages. I did take your branch for a quick test and for basic use cases it actually worked out of the box for all the supported storages (since you're using existing storage methods this was somewhat expected). |
Beta Was this translation helpful? Give feedback.
-
Hi,
I was learning about rate limiters and found this article from the Cloudflare blog. It explains how they built a limiter that:
I find this very interesting, as I currently use the moving window algorithm in production and I would like to optimize the RAM usage. I tried to make a POC that implements their article. It seems to be working with an in-memory limiter (
10 requests per 10 seconds
):Of course, the implementation is "naive". I guess the actions should be atomic. I am a simple user of Redis and MongoDB but I could try to look at a proper implementation.
Is it worth going further?
Thank you for your attention!
Edit: seems like it's just the Sliding window counter algorithm, it wasn't invented by Cloudflare.
Beta Was this translation helpful? Give feedback.
All reactions