This Load Balancer distributes incoming traffic evenly across a set of servers using a round-robin
algorithm.
- Docker
git clone <repository-url>
docker compose build
docker compose up
This compiles the application. Compiled binaries are located at target/x86_64-unknown-linux-gnu/release/load_balancer
.
- Prepare the Hosts File: Create a
hosts.txt
file containing the addresses of the upstream hosts that will receive traffic. For example:
0.0.0.0:8001
0.0.0.0:8002
- Make Executable: Grant execution permissions to the load balancer binary:
chmod +x load_balancer
- Start the Load Balancer: Launch the load balancer with default settings:
./load_balancer
This command will start the load balancer on the default port (8080).
- Custom Configuration: Optionally, start the load balancer with custom configuration:
./load_balancer -p 6060 -h /path/to/hosts.txt -w 4
Short | Long | Description | Default |
---|---|---|---|
-p |
--port |
Port to listen on | 8080 |
-h |
--hosts |
Path to upstream hosts | ./hosts.txt |
-w |
--workers |
Number of worker threads | 4 |
Build path :
target/x86_64-unknown-linux-gnu/release/load_balancer