Skip to content

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

# 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

go run dummy-golang.go 9001
go run dummy-golang.go 9002

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

# Start TCP servers
nc -lk 6001 &
nc -lk 6002 &

# Connect via BalancerX
telnet localhost 9090

๐Ÿค Contributing

Contributions and suggestions are welcome!


๐Ÿ“œ License

AGPLv3 ยฉ 2025 Nishant


BalancerX is developed and maintained by Nishant.