Implemented 6 different load balancing algorithms which redirect incoming loads using a reverse proxy server in Python. The six algorithms are:
- Round Robin
- Sticky Round Robin
- Weighted Round Robin
- IP hash
- Least Connections
- Least Response Time
To run the application, first run the backend servers, like so:
python3 -m http.server 8001
python3 -m http.server 8002
python3 -m http.server 8003
Then start redis server in a new terminal with the following command: redis-server
Make sure it is running on the default port of 6379
Then the different instances of the reverse proxy can be invoked via the following commands:
- python3 reverse_proxy.py --lb_algorithm='rr_simple'
- python3 reverse_proxy.py --lb_algorithm='rr_sticky'
- python3 reverse_proxy.py --lb_algorithm='rr_weighted'
- python3 reverse_proxy.py --lb_algorithm='ip_hash'
- python3 reverse_proxy.py --lb_algorithm='least_conns'
- python3 reverse_proxy.py --lb_algorithm='least_response_time'
You can then curl this reverse proxy server to see the load balancing algorithm in action: