All Projects → EvoluxBR → python-redis-rate-limit

EvoluxBR / python-redis-rate-limit

Licence: other
Python Rate Limiter implemented based on Redis INCR, EXPIRE, EVALSHA and EVAL.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to python-redis-rate-limit

zlimiter
A toolkit for rate limite,support memory and redis
Stars: ✭ 17 (-83.65%)
Mutual labels:  rate-limiting
ratelimiter
A concurrent rate limiter library for Golang based on Sliding-Window rate limiter algorithm.
Stars: ✭ 218 (+109.62%)
Mutual labels:  rate-limiting
gatekeeper
Rate limiting middleware for Vapor 👮
Stars: ✭ 54 (-48.08%)
Mutual labels:  rate-limiting
p-ratelimit
Promise-based utility to make sure you don’t call rate-limited APIs too quickly.
Stars: ✭ 49 (-52.88%)
Mutual labels:  rate-limiting
flaps
🛬 Modular rate limiting for PHP.
Stars: ✭ 64 (-38.46%)
Mutual labels:  rate-limiting
rush
rush.readthedocs.io/en/latest/
Stars: ✭ 42 (-59.62%)
Mutual labels:  rate-limiting
gcra-ruby
Generic cell rate algorithm (leaky bucket) implementation for rate limiting
Stars: ✭ 49 (-52.88%)
Mutual labels:  rate-limiting
adaptive throttler
manages multiple throttlers with ability to ramp up and down
Stars: ✭ 31 (-70.19%)
Mutual labels:  rate-limiting
phalcon-throttler
Phalcon Throttler is a Rate Limiter for the PHP Phalcon Framework.
Stars: ✭ 19 (-81.73%)
Mutual labels:  rate-limiting
Spring-Boot-Application-Template
Spring Boot Web App, Flyway, MySQL, H2DB, Bootstrap, Thymeleaf, JWT, Swagger, API Rate Limiting, Docker, RBAC, i18n
Stars: ✭ 90 (-13.46%)
Mutual labels:  rate-limiting
flood-protection
Flood protection for realtime applications
Stars: ✭ 19 (-81.73%)
Mutual labels:  rate-limiting
resque-waiting-room
Resque plugin that throttles your jobs
Stars: ✭ 34 (-67.31%)
Mutual labels:  rate-limiting
limits
Rate limiting using various strategies and storage backends such as redis & memcached
Stars: ✭ 178 (+71.15%)
Mutual labels:  rate-limiting
gentle-force
Brute-force, error and request rate limiting
Stars: ✭ 45 (-56.73%)
Mutual labels:  rate-limiting
go-ratelimit
Ratelimit your methods using Redis
Stars: ✭ 37 (-64.42%)
Mutual labels:  rate-limiting
flume
A blazing fast job processing system backed by GenStage & Redis.
Stars: ✭ 37 (-64.42%)
Mutual labels:  rate-limiting
db wlan manager
Monitors your Wifi to keep you logged in and resets your Wifi, if your data is drained
Stars: ✭ 23 (-77.88%)
Mutual labels:  rate-limiting
FireflySoft.RateLimit
It is a rate limiting library based on .Net standard.
Stars: ✭ 76 (-26.92%)
Mutual labels:  rate-limiting
Abp.AspNetCoreRateLimit
An Abp module helps you control how often your service is used.
Stars: ✭ 19 (-81.73%)
Mutual labels:  rate-limiting
RateLimiting.NET
Rate Limiting (debounce, throttle) for C# Portable Class Library
Stars: ✭ 20 (-80.77%)
Mutual labels:  rate-limiting

python-redis-rate-limit

This lib offers an abstraction of a Rate Limit algorithm implemented on top of Redis >= 2.6.0.

Supported Python Versions: 2.7, 3.5+

Example: 10 requests per second

from redis_rate_limit import RateLimit, TooManyRequests
try:
  with RateLimit(resource='users_list', client='192.168.0.10', max_requests=10):
    return '200 OK'
except TooManyRequests:
  return '429 Too Many Requests'

Example: using as a decorator

from redis_rate_limit import RateLimit, TooManyRequests

@RateLimit(resource='users_list', client='192.168.0.10', max_requests=10)
def list_users():
  return '200 OK'

try:
  return list_users()
except TooManyRequests:
  return '429 Too Many Requests'

Example: 600 requests per minute

from redis_rate_limit import RateLimit, TooManyRequests
try:
  with RateLimit(resource='users_list', client='192.168.0.10', max_requests=600, expire=60):
    return '200 OK'
except TooManyRequests:
  return '429 Too Many Requests'

Example: 100 requests per hour

from redis_rate_limit import RateLimit, TooManyRequests
try:
  with RateLimit(resource='users_list', client='192.168.0.10', max_requests=100, expire=3600):
    return '200 OK'
except TooManyRequests:
  return '429 Too Many Requests'

Example: you can also setup a factory to use it later

from redis_rate_limit import RateLimiter, TooManyRequests
limiter = RateLimiter(resource='users_list', max_requests=100, expire=3600)
try:
  with limiter.limit(client='192.168.0.10'):
    return '200 OK'
except TooManyRequests:
  return '429 Too Many Requests'

Example: you can also pass an optional Redis Pool

import redis
from redis_rate_limit import RateLimit, TooManyRequests
redis_pool = redis.ConnectionPool(host='127.0.0.1', port=6379, db=0)
try:
  with RateLimit(resource='users_list', client='192.168.0.10', max_requests=10, redis_pool=redis_pool):
    return '200 OK'
except TooManyRequests:
  return '429 Too Many Requests'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].