Skip to content

BigBlackWolf/rate_limiter

Repository files navigation

Rate Limiter

Rate Limiter is a Python reverse proxy designed to manage and enforce rate limits in applications. It provides a simple and flexible interface for controlling the rate of requests or actions within a specified time frame, leveraging header identifier of userId.

Code style: black

Quick start

Manual setup

Install all dependencies

pip install poetry
poetry install

Then run

uvicorn src.rate_limiter.main:app --port 8000

Via docker

docker compose up --build

Configuration

In order to set the limits of adjust the window correct the values in example.env and rename it to .env

  • RATE_LIMITER_NUMBER_OF_TOKENS - Number of requests allowed per amount of time
  • RATE_LIMITER_WINDOW - Time is seconds, after which counter will be reset
  • RATE_LIMITER_LIMIT - The limit, which can be acheived by summing tokens from the past. If different from 0, limiter will work in accumulator mode and sum up unused requests from previous time frame.

Features

  • Support in-memory tracking request counts
  • Flexible rate limit configurations
  • Easy integration into the applications
  • Support for both in-memory and Redis storage for tracking request counts

Development

For running test install correcponding dependancies

poetry install --with dev

Running load tests

cd tests/
locust

Then open http://localhost:8089/ in your browser for configuring numbers of running users

Contributing

Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on GitHub.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published