Step 1. Pre-requisite#
- •Python
- •Docker
- •Docker Compose
Step 2. Clone the repository#
Step 3. Run docker compose or install redis manually#
If you install redis manually open django-backend/configuration folder and copy .env.example
to create .env
. And provide the values for environment variables - REDIS_HOST: Redis server host - REDIS_PORT: Redis server port - REDIS_DB: Redis server db index - REDIS_PASSWORD: Redis server password
Step 4. Setup and run#
Install python, pip and venv (on mac: https://installpython3.com/mac/)
Use python version: 3.8
Step 5. Accessing the rate limiting app
How it works?#
How the data is stored:#
This app will block connections from a client after surpassing certain amount of requests (default: 10) per time (default: 10 sec) The application will return after each request the following headers. That will let the user know how many requests they have remaining before the run over the limit. On the 10th run server should return an HTTP status code of 429 Too Many Requests
SETNX is short for "SET if Not eXists". It basically sets key to hold string value if key does not exist. In that case, it is equal to SET. When key already holds a value, no operation is performed. New responses are added key-ip as shown below:
Set a timeout on key:
How the data is accessed:#
Next responses are get bucket:
Next responses are changed bucket: