django-redis-ratelimit
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
Metadata
Release files for django-redis-ratelimit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-redis-ratelimit-0.1.1.tar.gz | 3.6 kB | Without provenance | Details for django-redis-ratelimit-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_redis_ratelimit-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_redis_ratelimit-0.1.1-py2.py3-none-any.whl |
Total release size: 9.7 kB
Release files / django-redis-ratelimit-0.1.1.tar.gz
| Download URL | django-redis-ratelimit-0.1.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a7084a4898b9d3c411521173652d09a8299723c05aebd3e6c464bc94798e041
|
|
BLAKE2b-256 checksum How to use checksums |
b5ef2c5d7e565874b8d631e24b598d9a7575b9520aa2e604862e544872fcba92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_redis_ratelimit-0.1.1-py2.py3-none-any.whl
| Download URL | django_redis_ratelimit-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
56a4be337c698250c78fdc216117a67b1c062ca6f79e3b8e386e989e193113a7
|
|
BLAKE2b-256 checksum How to use checksums |
0bc638acdb546ea477ef4fd13192547c403dd176db69671a82b25455f0957819
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-redis-ratelimit 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.