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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-redis-ratelimit-0.1.1.tar.gz.
File metadata
- Download URL: django-redis-ratelimit-0.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a7084a4898b9d3c411521173652d09a8299723c05aebd3e6c464bc94798e041
|
|
| MD5 |
27ce17a69da08434861e70faa9ce17cf
|
|
| BLAKE2b-256 |
b5ef2c5d7e565874b8d631e24b598d9a7575b9520aa2e604862e544872fcba92
|
File details
Details for the file django_redis_ratelimit-0.1.1-py2.py3-none-any.whl.
File metadata
- Download URL: django_redis_ratelimit-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56a4be337c698250c78fdc216117a67b1c062ca6f79e3b8e386e989e193113a7
|
|
| MD5 |
8dd7c3c3033a7c5d950c4583b1ab63dc
|
|
| BLAKE2b-256 |
0bc638acdb546ea477ef4fd13192547c403dd176db69671a82b25455f0957819
|