Skip to content

arunjayakumar01/load_balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load Balancer

Load Balancer

This Load Balancer distributes incoming traffic evenly across a set of servers using a round-robin algorithm.

Prerequisites

  • Docker

Setup

Clone the Repository

git clone <repository-url>

Build the Docker Environment

docker compose build

Deployment

Create the Build

docker compose up

This compiles the application. Compiled binaries are located at target/x86_64-unknown-linux-gnu/release/load_balancer.

Running the Load Balancer

  1. 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
  1. Make Executable: Grant execution permissions to the load balancer binary:
chmod +x load_balancer
  1. 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).

  1. Custom Configuration: Optionally, start the load balancer with custom configuration:
./load_balancer -p 6060 -h /path/to/hosts.txt -w 4

Command-Line Arguments

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