django-throttle-requests
django-throttle-requests copied to clipboard
NUM_BUCKETS not clearly documented
Try as I might, I can't seem to wrap my head around what this config value is exactly and the docs don't explain it (or the others for that matter, but I've managed to figure those out I think). Any chance of getting a description?
I'm surprised anyone is looking at this, tbh :)
To answer your question, a throttle zone's NUM_BUCKETS represents an unimplemented feature, and will probably be deprecated/removed.
The intent was to allow the backing store to keep a certain amount of history of the number of calls made per user. For example, if your BUCKET_INTERVAL is 15 minutes, and you had NUM_BUCKETS set to 4, you would have 60 minutes' worth of current and historical data per user.
Since that will likely not get implemented unless someone really really wants it, my advice would be to keep NUM_BUCKETS set to 2. If it is less than two, an exception will be thrown by the @throttle decorator.
Thanks for the answer, much appreciated. My testing so far is quite positive - I think we'll be adding throttling in several places in our next release.
It has been in production for over a year and a half without issue using CacheBackend. We had a custom VARY class which looked at the requesters' oauth token, falling back to remote IP address if no oauth token was sent.
How will you be using it?
We'll be using the CacheBackend as well to rate-limit IP requests on a few pages.
One more thing I'd like to clarify: it appears that BUCKET_INTERVAL is approximately half of what you configure it to be: I have one set to 30 seconds but I only get catches for 15, one for an hour that only catches for about 30 minutes. Does that have something to do with NUM_BUCKETS or am I just using BUCKET_INTERVAL wrong? I assumed it was in seconds.
Closing this as NUM_BUCKETS is no longer used