HTTP-based throttling echo service
written by Ege Atesalp
POST /echo - Returns as response the JSON body of the request
GET /rate - Returns as response the request limit of the throttling functionality
POST /rate - Changes the request limit of the throttling functionality, returns the updated request limit
In root directory
Install the required modules in requirements.txt using the preffered dependency manager
# Pull and run the redis container, skip if already running
docker-compose up redis
# Run the app from port 8000, listens Redis from 6379
# If running locally, change the host parameter in redis.Redis() to 'localhost'
python main.py
docker-compose up
In root directory(docker or local)
pytest
It is normal for the testing to take approximately 65 seconds, since it tests the 60 sliding window of the throttling functionality
- Improve asynchronous handling -Comment: Especially important for scalability, better leverages ASGI
- Create individual testing -Comment: Testing with multiple tests affected the results, specifically because the database values were incosistent inbetween.
- Add functionality to make the middleware (throttling) only handle specific requests (/echo)