A multi-threaded TCP load balancer built in Python that distributes incoming client requests across multiple backend servers using a round-robin algorithm. The project includes fault tolerance, concurrent client handling, and demonstration scripts for backend servers and clients.
- Round-robin load balancing
- Multi-threaded request handling
- Fault-tolerant backend selection
- Simulated backend echo servers
- Interactive client for testing
- Modular and extensible architecture
| File | Description |
|---|---|
load_balancer.py |
Main load balancer that distributes requests across available backends |
backend_server.py |
Simple echo server simulating a backend server |
client_demo.py |
Command-line client for sending messages to the load balancer |
Run each backend server on a separate terminal with a unique port and ID:
python backend_server.py 9001 A
python backend_server.py 9002 B
python backend_server.py 9003 Cpython load_balancer.pyBy default, it listens on 127.0.0.1:8000.
python client_demo.pyEnter messages via the terminal to test request routing through the load balancer.
- TCP socket programming
- Thread-based concurrency
- Load balancing algorithms (round-robin)
- Basic fault handling and backend failover
- Scalable client-server architecture
- Add support for least-connections or IP-hash routing
- Implement health checks for backends
- Add HTTPS/TLS support
- Create a web dashboard for monitoring traffic
- Dockerize and deploy in a containerized environment