A high-performance network traffic management system that optimizes server resource utilization and request processing.
Inefficient server load distribution leads to performance bottlenecks, uneven resource allocation, and potential service disruptions during high-traffic scenarios.
- Shortest Queue Load Balancing
- Concurrent Client-Server Model
- Scalable Request Handling
- Efficient traffic distribution using Shortest Queue Strategy
- Concurrent handling of multiple client connections
- Reduced server response times
- Improved overall system reliability
- Object-Oriented Programming (OOP)
- Socket Programming
- Concurrent Programming
- UDP Protocol Implementation
- Python Development
- Implements the Shortest Queue Strategy
- Handles request distribution
- Manages server connections
- Monitors server health
- Manages server pool
- Implements load balancing logic
- Processes client requests
- Maintains request queue
- Reports health status
- Sends requests to load balancer
- Handles responses
- Implements retry logic
- ClientRequest: Structure for client requests
- ClientResponse: Format for responses to clients
- ControllerRequest: Internal control messages
- ServerResponse: Server status and health updates
The config.json
file contains all system settings:
{
"server": {
"count": "1",
"port_range_start": "50000",
"port_range_end": "51000",
"start_id": "0",
"queue_update_interval": "10"
},
"client": {
"count": "10",
"port_range_start": "51000",
"port_range_end": "52000",
"start_id": "1000"
},
"load_balancer": {
"server_side_port": "54000",
"client_side_port": "54001",
"server_scaling_threshold": "5"
},
"controller": {
"port": "55000"
}
}
- Clone the repository
git clone https://github.com/your-username/load-balancer.git
cd load-balancer
- Set up virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Start the Load Balancer
python loadbalancer.py
- Start the Controller
python controller.py
- Launch Servers
python server.py --port 8081
python server.py --port 8082
- Run Test Client
python client.py --requests 100
Logs are organized in three directories:
logs/clients/
: Client operation logslogs/controller/
: System control logslogs/servers/
: Individual server logs
.
├── client.py # Client implementation for sending requests
├── config.json # Configuration settings for the system
├── controller.py # Controller logic for managing load balancing
├── loadbalancer.py # Main load balancer implementation
├── server.py # Server implementation for handling requests
├── README.md # Project documentation
├── logs/ # Log files directory
│ ├── clients/ # Client-specific logs
│ ├── controller/ # Controller operation logs
│ └── servers/ # Server-specific logs
└── model/ # Data models
├── ClientRequest.py # Client request model
├── ClientResponse.py # Client response model
├── ControllerRequest.py # Controller request model
└── ServerResponse.py # Server response model