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.
Install all dependencies
pip install poetry
poetry install
Then run
uvicorn src.rate_limiter.main:app --port 8000
Via docker
docker compose up --build
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.
- 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
For running test install correcponding dependancies
poetry install --with dev
cd tests/
locust
Then open http://localhost:8089/ in your browser for configuring numbers of running users
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on GitHub.