BalancerX¶
BalancerX is a lightwright load balancer written in Go. It supports proxies in both HTTP and TCP, with multiple load balancing strategies, health checks -- all configurations controlled by config.yaml.
/etc/balancerx/config.yaml when installed with .deb package.
โจ Features¶
- ๐ Round-robin and Random load balancing strategies
- ๐ YAML-based configuration for HTTP or TCP protocols
- ๐ฉบ Active health checks: HTTP endpoint checks or TCP connection probes
- โก HTTP reverse proxy using
net/http/httputil - ๐ Logging: at
/var/log/balancerx/balancerx.log - ๐ง Easily extendable with new strategies and protocol support
- ๐ Health checker service (available but not yet integrated)
๐ Quick Start¶
Installation¶
Debian Package (Recommended)¶
# Download and install
wget https://github.com/nishujangra/balancerx/releases/latest/download/balancerx_1.0.0.deb
sudo dpkg -i balancerx_1.0.0.deb
# Start the service
sudo systemctl start balancerx
sudo systemctl enable balancerx
From Source¶
git clone https://github.com/nishujangra/balancerx.git
cd balancerx
go build -o build/balancerx main.go
./build/balancerx -config=config.yaml
Basic Configuration¶
Create a config.yaml file:
port: 8080
protocol: http
strategy: round-robin # or random
backends:
- http://localhost:9001
- http://localhost:9002
- http://localhost:9003
health_check:
path: /health
๐ Performance¶
BalancerX demonstrates excellent performance characteristics:
| Load Balancer | Binary Size | Memory Usage (RSS) | Package Files |
|---|---|---|---|
| BalancerX | 9.4M | 2,468 KB | 18 files |
| nginx | 1.3M | Not running | 12 files |
Key Benefits¶
- Low Memory Footprint: Only ~2.5MB RAM usage
- Fewer Dependencies โ Leaner binary & fewer attack surfaces
- Native Go HTTP โ Predictable, no framework bloat
- Smart Goroutine Management โ Scalable concurrency without memory blowups
๐ Supported Protocols¶
| Protocol | Description |
|---|---|
http |
Reverse proxy for HTTP with health checks and header handling |
tcp |
Transparent forwarding of raw TCP connections with basic health checks |
โ๏ธ Load Balancing Strategies¶
| Name | Description |
|---|---|
round-robin |
Cycles through backends in fixed order |
random |
Randomly selects a backend per request |
least-conn |
(Planned) Chooses backend with fewest connections |
ip-hash |
(Planned) Sticky routing by client IP hash |
๐งช Testing¶
HTTP Backends¶
Sample backend server using golang is provided in dummy-server/dummy-golang.go. Copy that sample backend server if you want to try BalancerX in your local-system
or You can use your own server but that server must have health check route you provided and if not provided in config.yaml then /health is the default endpoint for health check
or
# For running dummy serves from port 9000 to 9100
for i in $(seq 9000 9100); do
go run dummy-golang.py $i &
done
# Stop running servers from port 9000 to 9100
for port in $(seq 9000 9100); do
pid=$(lsof -t -i:$port)
if [ -n "$pid" ]; then
kill -9 $pid
fi
done
TCP Backends¶
๐ค Contributing¶
Contributions and suggestions are welcome!
๐ License¶
AGPLv3 ยฉ 2025 Nishant
BalancerX is developed and maintained by Nishant.