django-throttle-requests icon indicating copy to clipboard operation
django-throttle-requests copied to clipboard

NUM_BUCKETS not clearly documented

Open indigodomo opened this issue 10 years ago • 5 comments

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?

indigodomo avatar Sep 27 '14 00:09 indigodomo

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.

sobotklp avatar Sep 27 '14 05:09 sobotklp

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.

indigodomo avatar Sep 27 '14 14:09 indigodomo

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?

sobotklp avatar Sep 27 '14 18:09 sobotklp

We'll be using the CacheBackend as well to rate-limit IP requests on a few pages.

indigodomo avatar Sep 29 '14 14:09 indigodomo

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.

indigodomo avatar Sep 29 '14 15:09 indigodomo

Closing this as NUM_BUCKETS is no longer used

sobotklp avatar Mar 08 '23 00:03 sobotklp