0 %

Balance Hub

Traffic distribution at the speed of infrastructure, designed for zero-config scale, built for full-control flexibility

Project

Open Source

Type

HTTP
Load Balancer

Technology

Golang, SQLite, Redis

Load Balancer Reverse Proxy Self Hosted Scalable backend

Features

no restarts, no config reloads, no downtime.

BalanceHub is built on a dual listener architecture, a full HTTP(S) reverse proxy and a binary control-plane. Backend servers self-register at runtime with fine-grained routing rules, building a live routing table with zero manual intervention.

Dynamic Server
Registration

Response
Caching

Fault
Tolerant

Traffic
Management

Custom
Protocol

Aync
Logging

config.yaml — Full Config Schema
Original-Server:
  allow:                   # control-plane subnet allowlist
    - 192.168.1.0/24
    - 127.0.0.0/24
BalanceHub:
  listen:        5000      # HTTP reverse proxy port
  tcpListener:   5050      # control-plane TCP port
  protocol:      HTTP      # HTTP | HTTPS
  algorithm:     Least-Connected
  access-logs-path: ./logs
  db-path:       ''
  redis-server:
    ip:            127.0.0.1
    port:          6379
    caching:       false
    cache-duration: 900     # seconds
Configuration

A single config.yaml governs every runtime behavior, from port binding to TLS mode to Redis topology. The file is parsed once at startup into a typed Go singleton. Servers can declare path-level affinity (e.g., serve only /api/v2/) and client-IP restrictions (individual IPs or CIDR subnets)

Custom TCP Protocol

Backends join or leave the cluster at runtime over the TCP control plane. Registration writes atomically updating in-memory routing table simultaneously. Rather than exposing an HTTP management API, BalanceHub implements a compact binary protocol over a raw TCP socket. Session-level pipelining allows multiple operations in a single connection.

Request Packet (Layer 2001)
L magic
B magic
0xF0 action
len payload sz
JSON{…} mappings
  • 0xF0 Add server / paths / clients
  • 0x0F Remove server / paths / clients
JSON payload deserializes into a Mappings struct: Port, Paths []string, Clients []string.
Response Packet (Layer 2002)
R magic
E magic
res result
len msg sz
msg human msg
  • 0xFF Operation succeeded
  • 0x00 Operation failed
Both DB write + routing-table update must succeed before 0xFF is returned. Partial failures are rolled back first.

Algorithms

Least-Connections routing directs each request to the backend with the fewest active connections, staying balanced under real traffic patterns.

An active health-check loop continuously monitors backends ensuring automatic recovery.

Technology
stack

Tech Stack Icon

Golang

Tech Stack Icon

Redis

Tech Stack Icon

Sqlite

Tech Stack Icon

Docker