Skip to main content

Distributed Redis rate limiter for Python APIs using sliding window algorithm

Project description

RateGuard

RateGuard is a distributed rate limiting library for Python APIs using Redis.

Features

  • Sliding Window Rate Limiting
  • Redis Sorted Sets
  • FastAPI Middleware
  • Distributed API protection
  • Works across multiple servers

How it works

RateGuard uses a Sliding Window Rate Limiting algorithm with Redis Sorted Sets.

  1. Each request is stored with a timestamp
  2. Old requests outside the window are removed
  3. Remaining requests are counted
  4. If the count exceeds the limit, the request is rejected

This design works across multiple API servers because Redis is shared.

Client → FastAPI → RateGuard → Redis → Decision

Run Example

uvicorn examples.fastapi_example:app --reload



## Installation

```bash
pip install -r requirements.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rate_guardian-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rate_guardian-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file rate_guardian-0.1.0.tar.gz.

File metadata

  • Download URL: rate_guardian-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.9

File hashes

Hashes for rate_guardian-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fcd7c8ba2129ad1b40509324bc330cff3326c38f7ddf07ccaf7580feb5fddb4e
MD5 de77056be66e54a6e4454cdfc9dae3e5
BLAKE2b-256 6125797dc345bd8d551c3ddb86b425c40cecae31d447736ef64fe33ff3d5151c

See more details on using hashes here.

File details

Details for the file rate_guardian-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rate_guardian-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.9

File hashes

Hashes for rate_guardian-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17b12eb8cf0b4f83835b93d4fe0f842e7703c66a564fcc2829ab68ca5bfd018c
MD5 5b5670a9c1f28e9292ac0eb770d76927
BLAKE2b-256 5611d42d703431a783e968a91b09d29fdd18a78d56738eb0ddc252559dcb3f02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page