Skip to content
srujaniyengarPublic
forked from pushkar-gr/Deston

About

A L7 & L4 load balancer built using rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Deston - A Rust-based L7 & L4 Load Balancer

Deston - A Rust-based L7 & L4 Load Balancer

Build Status License Rust Version Issues Contributors

Deston is an advanced Layer 4 (L4) and Layer 7 (L7) load balancer built with Rust. It provides robust performance, scalability, and fine-grained control for managing high-volume traffic across backend server infrastructures.


✨ Features

  • Dual support for L4 and L7 load balancing.
  • Modular Design: Clean separation of concerns using Rust modules (config, server, load_balancer).
  • Highly Scalable: Built with tokio for asynchronous, non-blocking server connections.
  • Pluggable Algorithms:
    • Round Robin
    • Weighted Round Robin
    • IP Hashing
  • Smart Server Health Checks: Tracks response time, active connections, etc.
  • Customizable:
    • Easy configuration through config.toml.
    • Supports dynamic addition of backend servers.

🎯 Project Architecture and Workflow

High-Level Overview of Deston's Functionality:

flowchart TD
    Client(Client Requests)
    subgraph Deston Load Balancer
    L7[Layer 7 Load Balancer<br>HTTP/HTTPS]
    L4[Layer 4 Load Balancer<br>TCP/UDP Streams]
    end
    Backend[Backend Servers]
  
    Client ==> L7
    L7 --> L4
    L4 --> Backend
Loading
  1. Accepts client requests, either HTTP (Layer 7) or generic TCP/UDP streams (Layer 4).
  2. Forwards the traffic to backend servers after running load-balancing algorithms.
  3. Continuously monitors backend server health and adjusts routing dynamically.

πŸš€ Quick Start

Prerequisites

  • Rust 1.70+ (Install from rustup)
  • Ensure cargo is available for building and running.

Build

cargo build --release

Run

cargo run --release

Configuration

Modify config.toml to add servers, specify load-balancing algorithms, etc.:

[load_balancer]
address = "127.0.0.1"
port = 8080
algorithm = "RoundRobin"

[[server]]
address = "http://127.0.0.1:3000"
port = 3000

[[server]]
address = "http://127.0.0.1:3001"
port = 3001

πŸ“œ Code Snippets

Here is a glimpse of some of Deston's key components:

Layer 4 Load Balancing

pub struct Layer4 {
    config: SyncConfig,
}

impl load_balancer::LoadBalancer for Layer4 {
    async fn start(&self) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
        let lb_address = "http://127.0.0.1:8000".parse::<Uri>().unwrap();
        let listener = TcpListener::bind((host, port)).await?;

        loop {
            let (stream, addr) = listener.accept().await?;
            tokio::task::spawn(async move { ... });
        }
    }
}

πŸ› οΈ Contributors

Deston warmly welcomes contributors! πŸš€


πŸ“„ License

This repository is licensed under the MIT License. See the LICENSE file for more details.


🌟 Acknowledgements

Built using:

  • Tokio for asynchronous runtime.
  • Hyper for HTTP requests handling.

Build Status License Rust Version Issues Contributors

Deston is an advanced Layer 4 (L4) and Layer 7 (L7) load balancer built with Rust. It provides robust performance, scalability, and fine-grained control for managing high-volume traffic across backend server infrastructures.


✨ Features

  • Dual support for L4 and L7 load balancing.
  • Modular Design: Clean separation of concerns using Rust modules (config, server, load_balancer).
  • Highly Scalable: Built with tokio for asynchronous, non-blocking server connections.
  • Pluggable Algorithms:
    • Round Robin
    • Weighted Round Robin
    • IP Hashing
  • Smart Server Health Checks: Tracks response time, active connections, etc.
  • Customizable:
    • Easy configuration through config.toml.
    • Supports dynamic addition of backend servers.

🎯 Project Architecture and Workflow

High-Level Overview of Deston's Functionality:

flowchart TD
    Client(Client Requests)
    subgraph Deston Load Balancer
    L7[Layer 7 Load Balancer<br>HTTP/HTTPS]
    L4[Layer 4 Load Balancer<br>TCP/UDP Streams]
    end
    Backend[Backend Servers]
  
    Client ==> L7
    L7 --> L4
    L4 --> Backend
Loading
  1. Accepts client requests, either HTTP (Layer 7) or generic TCP/UDP streams (Layer 4).
  2. Forwards the traffic to backend servers after running load-balancing algorithms.
  3. Continuously monitors backend server health and adjusts routing dynamically.

πŸš€ Quick Start

Prerequisites

  • Rust 1.70+ (Install from rustup)
  • Ensure cargo is available for building and running.

Build

cargo build --release

Run

cargo run --release

Configuration

Modify config.toml to add servers, specify load-balancing algorithms, etc.:

[load_balancer]
address = "127.0.0.1"
port = 8080
algorithm = "RoundRobin"

[[server]]
address = "http://127.0.0.1:3000"
port = 3000

[[server]]
address = "http://127.0.0.1:3001"
port = 3001

πŸ“œ Code Snippets

Here is a glimpse of some of Deston's key components:

Layer 4 Load Balancing

pub struct Layer4 {
    config: SyncConfig,
}

impl load_balancer::LoadBalancer for Layer4 {
    async fn start(&self) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
        let lb_address = "http://127.0.0.1:8000".parse::<Uri>().unwrap();
        let listener = TcpListener::bind((host, port)).await?;

        loop {
            let (stream, addr) = listener.accept().await?;
            tokio::task::spawn(async move { ... });
        }
    }
}

πŸ› οΈ Contributors

Deston warmly welcomes contributors! πŸš€


πŸ“„ License

This repository is licensed under the MIT License. See the LICENSE file for more details.


🌟 Acknowledgements

Built using:

  • Tokio for asynchronous runtime.
  • Hyper for HTTP requests handling.

About

A L7 & L4 load balancer built using rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages