Skip to content

darrendc26/load-balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Load Balancer

A simple, high-performance load balancer built in Rust using asynchronous networking. It accepts incoming TCP connections and forwards them to healthy backend servers using round-robin logic. Designed to be minimal, educational, and extensible.

Features

Asynchronous TCP networking (based on tokio) Round-robin backend selection Thread-safe shared state via Arc<Mutex<_>>

How It Works

Starts a TCP listener on a specified frontend port.

Accepts incoming client connections.

Selects a backend server from the pool using round-robin.

Forwards data bidirectionally between client and selected backend.

Run the program

Clone the Repo

git clone https://github.com/darrendc26/load-balancer.git
cd load-balancer
cargo run

Start a few servers to test

python3 -m http.server 5000
python3 -m http.server 5001
python3 -m http.server 5002

Now connect via curl

curl http://127.0.0.1:8080

You will recieve a response from one of the servers as it is routed to these servers based on Round Robin Algorithm.

About

A load balancer implementation in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages