High-Performance Load Balancer Built with Rust
RustStrom is a modern load balancer written in Rust. It distributes HTTP/HTTPS traffic across multiple backend servers, manages SSL certificates automatically, and delivers high performance.
- β‘ High Performance - Rust's speed and safety
- π Load Balancing Algorithms - Round Robin, Random, IP Hash, Least Connection, Sticky Cookie
- π Health Checking - Automatic backend server monitoring
- π SSL/TLS - Automatic certificates via Let's Encrypt
- π§ Middlewares - Compression, Rate Limiting, HTTPS Redirect, and more
- π₯ Hot Reload - Configuration changes without restart
- π Prometheus Metrics - Built-in monitoring support
curl -sSL https://raw.githubusercontent.com/ismoilovdevml/RustStrom/main/install.sh | bash# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone repository
git clone https://github.com/ismoilovdevml/RustStrom.git
cd RustStrom
# Build
cargo build --release
# Binary location
./target/release/rust-stromCreate /etc/rust-strom/config.toml:
# Network settings
http_address = "[::]:80"
https_address = "[::]:443"
# Health check interval
[health_interval]
check_every = 10 # seconds
# Backend pool
[[backend_pools]]
matcher = "Host('example.com')"
addresses = ["127.0.0.1:8080", "127.0.0.1:8081", "127.0.0.1:8082"]
schemes = ["HTTP", "HTTPS"]
strategy = { RoundRobin = {} }
# Health check settings
[backend_pools.health_config]
slow_threshold = 300 # milliseconds
timeout = 500 # milliseconds
path = "/"[certificates."example.com"]
ACME = {
staging = false,
email = "[email protected]",
persist_dir = "/var/lib/rust-strom/acme"
}[certificates."example.com"]
Local = {
certificate_path = "/etc/ssl/certs/example.com.crt",
private_key_path = "/etc/ssl/private/example.com.key"
}# Round Robin - Sequential distribution
strategy = { RoundRobin = {} }
# Random - Random selection
strategy = { Random = {} }
# IP Hash - IP-based routing
strategy = { IPHash = {} }
# Least Connection - Least active connections
strategy = { LeastConnection = {} }
# Sticky Cookie - Session persistence
[backend_pools.strategy.StickyCookie]
cookie_name = "RUSTSTROM_SESSION"
http_only = true
secure = true
same_site = "Strict"
inner = { RoundRobin = {} }# Create systemd service file
sudo nano /etc/systemd/system/rust-strom.service[Unit]
Description=RustStrom Load Balancer
After=network.target
[Service]
Type=simple
User=rust-strom
Group=rust-strom
ExecStart=/usr/local/bin/rust-strom --config /etc/rust-strom/config.toml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target# Start service
sudo systemctl daemon-reload
sudo systemctl enable rust-strom
sudo systemctl start rust-strom
sudo systemctl status rust-stromrust-strom --config /etc/rust-strom/config.tomlPrometheus metrics available at /metrics endpoint:
curl http://localhost:9090/metricsruststrom_requests_total- Total requestsruststrom_request_duration_seconds- Request durationruststrom_active_connections- Active connectionsruststrom_backend_health- Backend server healthruststrom_rate_limit_exceeded_total- Rate limit hits
# Systemd logs
sudo journalctl -u rust-strom -f
# Debug mode
RUST_LOG=debug rust-strom --config /etc/rust-strom/config.tomlrust-strom --config /etc/rust-strom/config.toml --checkRustStrom is distributed under the GPL-3.0 license.