Skip to content

Latest commit

History

361 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

OpenLoadBalancer

Minimal-dependency L4/L7 load balancer for any backend. One binary. Written in pure Go. Only stdlib + golang.org/x/{crypto,net,text} — no external frameworks. Works with Node.js, Python, Java, Go, Rust, .NET, PHP — anything that speaks HTTP or TCP.

OpenLoadBalancer

WebsiteReleaseGoLicenseCoverageMinimal Deps

Quick Start

curl -sSL https://openloadbalancer.dev/install.sh | sh

Create olb.yaml (or run olb setup for an interactive wizard):

admin:
address: "127.0.0.1:8081"listeners:
- name: httpaddress: ":80"routes:
- path: /pool: webpools:
- name: webalgorithm: round_robinbackends:
- address: "10.0.1.10:8080"
- address: "10.0.1.11:8080"health_check:
type: httppath: /healthinterval: 10s
olb start --config olb.yaml

That's it. HTTP proxy on :80, admin API on :8081, health checks every 10s, round-robin across two backends.

Install

# Linux / macOS
curl -sSL https://openloadbalancer.dev/install.sh | sh
# Windows (PowerShell)
irm https://openloadbalancer.dev/install.ps1 | iex
# Docker (GHCR)
docker pull ghcr.io/openloadbalancer/olb:latest
docker run -d -p 80:80 -p 8081:8081 \
-v ./olb.yaml:/etc/olb/configs/olb.yaml \
ghcr.io/openloadbalancer/olb:latest
# Homebrew
brew tap openloadbalancer/olb && brew install olb
# Build from source
git clone https://github.com/openloadbalancer/olb.git &&cd olb && make build

Requires Go 1.26+. Only stdlib + golang.org/x/{crypto,net,text}.

Features

Proxy: HTTP/HTTPS, WebSocket, gRPC, SSE, TCP (L4), UDP (L4), SNI routing, PROXY protocol v1/v2, Request Shadowing/Mirroring

Load Balancing: 16 algorithms — Round Robin, Weighted RR, Least Connections, Weighted Least Connections, Least Response Time, Weighted Least Response Time, IP Hash, Consistent Hash (Ketama), Maglev, Ring Hash, Power of Two, Random, Weighted Random, Rendezvous Hash, Peak EWMA, Sticky Sessions

Geo-DNS Routing: Geographic location-based traffic routing (country, region, city)

Security: TLS termination + SNI, ACME/Let's Encrypt, mTLS, OCSP stapling, 6-layer WAF (IP ACL, rate limiting, request sanitizer, detection engine with SQLi/XSS/path traversal/CMDi/XXE/SSRF, bot detection with JA3 fingerprinting, response protection with security headers + data masking), circuit breaker

Middleware: 16 components — Recovery, body limit, WAF (6-layer pipeline), IP filter, real IP, request ID, timeout, rate limit, circuit breaker, CORS, headers, compression (gzip), retry, cache, metrics, access log

Observability: Web UI dashboard (8 pages), TUI (olb top), Prometheus metrics, structured JSON logging, admin REST API (15+ endpoints), Grafana dashboard

Operations: Hot config reload (SIGHUP or API), Raft clustering + SWIM gossip, service discovery (Static/DNS/Consul/Docker/File), MCP server for AI integration, plugin system, 30+ CLI commands, distributed rate limiting, request shadowing/mirroring

MCP Integration (AI-Powered Management)

OpenLoadBalancer includes a built-in Model Context Protocol (MCP) server that enables AI agents (Claude, GPT, Copilot) to monitor, diagnose, and manage the load balancer.

Transport

  • SSE (Server-Sent Events): GET /sse for streaming + POST /message for commands — MCP spec compliant
  • HTTP POST: POST /mcp for simple request/response (backwards compatible)
  • Stdio: Line-delimited JSON-RPC over stdin/stdout for local CLI tools

Authentication

admin:
mcp_address: ":8082"mcp_token: "your-secret-token"# Bearer token authmcp_audit: true # Log all tool calls

17 MCP Tools

CategoryTools
Metricsolb_query_metrics — RPS, latency, error rates, connections
Backendsolb_list_backends, olb_modify_backend — Add, remove, drain, enable/disable
Routesolb_modify_route — Add, update, remove routes with traffic splitting
Diagnosticsolb_diagnose — Automated error/latency/capacity/health analysis
Configolb_get_config, olb_get_logs, olb_cluster_status
WAFwaf_status, waf_add_whitelist, waf_add_blacklist, waf_remove_whitelist, waf_remove_blacklist, waf_list_rules, waf_get_stats, waf_get_top_blocked_ips, waf_get_attack_timeline

Connect from Claude Desktop

{
"mcpServers": {
"olb": {
"url": "http://localhost:8082/sse",
"headers": {
"Authorization": "Bearer your-secret-token"
}
}
}
}

Performance

Benchmarked on AMD Ryzen 9 9950X3D:

MetricResult
Peak RPS15,480 (10 concurrent, round_robin)
Proxy overhead137µs (direct: 87µs → proxied: 223µs)
RoundRobin.Next3.5 ns/op, 0 allocs
Middleware overhead< 3% (full stack vs none)
WAF overhead (6-layer)~35μs per request, < 3% at proxy scale
Binary size~13 MB
P99 latency (50 conc.)22ms
Success rate100% across all tests
Algorithm comparison (1000 req, 50 concurrent)
AlgorithmRPSAvg LatencyDistribution
random12,9133.5ms32/34/34%
maglev11,5973.8ms68/2/30%
ip_hash11,0624.0ms75/12/13%
power_of_two10,7084.0ms34/33/33%
least_connections10,1194.4ms33/33/34%
consistent_hash8,8974.6ms0/0/100%
weighted_rr8,0425.6ms33/33/34%
round_robin7,3206.3ms35/33/32%
Full benchmark report

See docs/benchmark-report.md for the complete report including concurrency scaling, backend latency impact, and middleware overhead measurements.

E2E Verified

56+ end-to-end tests across 70 packages with 95.3% coverage:

CategoryVerified
ProxyHTTP, HTTPS/TLS, WebSocket, SSE, TCP, UDP
AlgorithmsRR, WRR, LC, IPHash, CH, Maglev, P2C, Random, RingHash
MiddlewareRate limit (429), CORS, gzip (98% reduction), WAF 6-layer (SQLi/XSS/CMDi/path traversal → 403, rate limit → 429, monitor mode, security headers, bot detection, IP ACL, data masking), IP filter, circuit breaker, cache (HIT/MISS), headers, retry
OperationsHealth check (down/recovery), config reload, weighted distribution, session affinity, graceful failover (0 downtime)
InfraAdmin API, Web UI, Prometheus, MCP server, multiple listeners
Performance15K RPS, 137µs proxy overhead, 100% success rate

Algorithms

AlgorithmConfig NameUse Case
Round Robinround_robinDefault, equal backends
Weighted Round Robinweighted_round_robinUnequal backend capacity
Least Connectionsleast_connectionsLong-lived connections
Least Response Timeleast_response_timeLatency-sensitive
IP Haship_hashSession affinity by IP
Consistent Hashconsistent_hashCache locality
MaglevmaglevGoogle-style hashing
Ring Hashring_hashConsistent with vnodes
Power of Twopower_of_twoBalanced random
RandomrandomSimple, no state

Configuration

Supports YAML, JSON, TOML, and HCL with ${ENV_VAR} substitution.

admin:
address: "127.0.0.1:8081"middleware:
rate_limit:
enabled: truerequests_per_second: 1000cors:
enabled: trueallowed_origins: ["*"]compression:
enabled: truewaf:
enabled: truemode: enforcedetection:
enabled: truethreshold: {block: 50, log: 25}bot_detection: {enabled: true, mode: monitor}response:
security_headers: {enabled: true}listeners:
- name: httpaddress: ":8080"routes:
- path: /apipool: api-pool
- path: /pool: web-poolpools:
- name: web-poolalgorithm: round_robinbackends:
- address: "10.0.1.10:8080"
- address: "10.0.1.11:8080"health_check:
type: httppath: /healthinterval: 5s
- name: api-poolalgorithm: least_connectionsbackends:
- address: "10.0.2.10:8080"weight: 3
- address: "10.0.2.11:8080"weight: 2

See docs/configuration.md for all options.

Geo-DNS Routing Example

geodns:
enabled: truedefault_pool: default-poolrules:
- id: us-trafficcountry: USpool: us-poolfallback: default-pool
- id: eu-trafficcountry: EUpool: eu-pool
- id: asia-trafficcountry: JPregion: Tokyopool: asia-pool

Request Shadowing Example

shadow:
enabled: truepercentage: 10.0# Mirror 10% of trafficcopy_headers: truecopy_body: falsetimeout: 30stargets:
- pool: staging-poolpercentage: 100.0

Distributed Rate Limiting Example

waf:
enabled: truerate_limit:
enabled: truestore:
type: redisaddress: "localhost:6379"database: 0rules:
- id: per-ipscope: iplimit: 1000window: 1m

CLI

olb setup # Interactive config wizard
olb start --config olb.yaml # Start proxy
olb stop # Graceful shutdown
olb reload # Hot-reload config
olb status # Server status
olb top # Live TUI dashboard
olb backend list # List backends
olb backend drain web-pool 10.0.1.10:8080
olb health show # Health check status
olb config validate olb.yaml # Validate config
olb cluster status # Cluster info

Architecture

 ┌─────────────────────────────────────────────────┐
│ OpenLoadBalancer │
Clients ─────────┤ │
HTTP/S, WS, │ Listeners → Middleware → Router → Balancer → Backends
gRPC, TCP, UDP │ (L4/L7) (16 types) (trie) (16 algos) │
│ │
│ WAF (6 layers) │ TLS │ Cluster │ MCP │ Web UI │
│ GeoDNS │ Shadow │ Discovery │ Prometheus │
└─────────────────────────────────────────────────┘

Documentation

GuideDescription
Getting StartedStep-by-step tutorial
ConfigurationAll config options
Production DeploymentProduction deployment guide
TroubleshootingTroubleshooting playbook
Migration GuideMigrate from NGINX/HAProxy/Traefik
AlgorithmsAlgorithm details
API ReferenceOpenAPI/Swagger spec
ClusteringMulti-node setup
WAFWeb Application Firewall (6-layer defense)
MCP / AIAI integration
BenchmarksPerformance data
SpecificationTechnical spec

Contributing

See CONTRIBUTING.md. Key rules:

  1. Minimal external deps — stdlib + golang.org/x/{crypto,net,text} only
  2. Tests required — 85% coverage, don't lower it
  3. All features wired — no dead code in engine.go
  4. gofmt + go vet — CI enforced

License

Apache 2.0 — LICENSE

About

High-performance zero-dependency L4/L7 load balancer written in Go. Single binary with Web UI, clustering, MCP/AI integration. 8.5K RPS, 39 E2E tests.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

25 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages