A fixed window rate limiting based on Redis
Project description
# django-redis-ratelimit
[](https://travis-ci.org/r00m/django-redis-ratelimit)
A fixed window rate limiting based on Redis
---
## Installation
To install django-redis-ratelimit, simply:
```console
$ pip install django-redis-ratelimit
```
**NB!** django-redis-ratelimit requires a running Redis server. See [Redis's quickstart](http://redis.io/topics/quickstart)
for installation instructions.
## Getting started
First, add the middleware to your `settings.py`:
```django
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:
```django
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
- [Redis Rate Limiting Pattern #2](https://redis.io/commands/INCR#pattern-rate-limiter-2)
## License
MIT
[](https://travis-ci.org/r00m/django-redis-ratelimit)
A fixed window rate limiting based on Redis
---
## Installation
To install django-redis-ratelimit, simply:
```console
$ pip install django-redis-ratelimit
```
**NB!** django-redis-ratelimit requires a running Redis server. See [Redis's quickstart](http://redis.io/topics/quickstart)
for installation instructions.
## Getting started
First, add the middleware to your `settings.py`:
```django
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:
```django
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
- [Redis Rate Limiting Pattern #2](https://redis.io/commands/INCR#pattern-rate-limiter-2)
## 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.0.tar.gz.
File metadata
- Download URL: django-redis-ratelimit-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2dec9aa0a0ae6077f34089db3c6914875349e162f195c9bb17460d151b00ee5
|
|
| MD5 |
5fc19893683c7d707bb6db211dfb2803
|
|
| BLAKE2b-256 |
82f1f57bd1f3e82eacee2ccaba1fe4d324e67ecbf439d0f8b390c46395289b18
|
File details
Details for the file django_redis_ratelimit-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: django_redis_ratelimit-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa2a4e584a36c78c5350b1eb1980ecb470b2923af21b54f56bc23739218935ae
|
|
| MD5 |
85e489814ae20f8d3b064e00f1753a15
|
|
| BLAKE2b-256 |
7d0e5235f380298dbe74f6a9da1054617f24d94fe7800855d557e9cac502e9a9
|