A fixed window rate limiting based on Redis
Project description
A fixed window rate limiting based on Redis
Requirements
Python >= 3.6
Django >= 1.11
Redis
Installation
To install django-redis-ratelimit, simply:
$ pip install django-redis-ratelimit
NB! django-redis-ratelimit requires a running Redis server. See Redis’s quickstart for installation instructions.
Getting started
First, add the middleware to your settings.py:
MIDDLEWARE = [
# ...
'redis_ratelimit.middleware.RateLimitMiddleware',
]
this will make sure that end user sees the HTTP 429 response.
Next, apply the ratelimit decorator to the view:
from django.http import HttpResponse
from redis_ratelimit import ratelimit
@ratelimit(rate='5/m')
def index(request):
return HttpResponse("Hello World!")
Memory requirements
For this example we will assume that each key takes up roughly 250 bytes and each value is 4 bytes:
250 + 4 * 1 million unique hits = ~254 Megabytes
Notes
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-redis-ratelimit-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a7084a4898b9d3c411521173652d09a8299723c05aebd3e6c464bc94798e041 |
|
MD5 | 27ce17a69da08434861e70faa9ce17cf |
|
BLAKE2b-256 | b5ef2c5d7e565874b8d631e24b598d9a7575b9520aa2e604862e544872fcba92 |
Close
Hashes for django_redis_ratelimit-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56a4be337c698250c78fdc216117a67b1c062ca6f79e3b8e386e989e193113a7 |
|
MD5 | 8dd7c3c3033a7c5d950c4583b1ab63dc |
|
BLAKE2b-256 | 0bc638acdb546ea477ef4fd13192547c403dd176db69671a82b25455f0957819 |