Load balance requests based on configured hostname accross configured backends. It is primarily meant to be used for learning purposes in a home lab environment.
- ⚙️ Simple configuration
- In-line
- ⚡️ Load Balancing
- Least-Loaded Round Robin
- Sticky Round Robin
- Round Robin
- Random
- First
- 💪 Resiliency
- Retries
- 📈 Dashboard
- Monitor
- Traffic
You can run RPLB
with these commands:
docker pull ghcr.io/dalibormesaric/rplb:latest
docker run -d --rm -p 8000:8000 -p 8080:8080 -e RPLB_F=myapp.example.com,myapp -e RPLB_B=myapp,http://10.0.0.1:1234,myapp,http://10.0.0.2:1234,myapp,http://10.0.0.3:1234 --memory="64m" --memory-reservation="64m" --cpus="1" ghcr.io/dalibormesaric/rplb:latest
RPLB_F=myapp.example.com,myapp
myapp.example.com
is hostname whereRPLB
is running, so in this case you would access your backend viahttp://myapp.example.com:8080
and the Dashboard viahttp://myapp.example.com:8000
myapp
is name of the Backend Pool that this hostname is connected to
RPLB_B=myapp,http://10.0.0.1:1234,myapp,http://10.0.0.2:1234,myapp,http://10.0.0.3:1234
myapp
is name of the Backend Pool to which the URL is assignedhttp://10.0.0.1:1234
,http://10.0.0.2:1234
andhttp://10.0.0.3:1234
are the URLs of your application
To run custom docker images, use Advanced SSH & Web Terminal from Community Add-ons.
To resolve custom domains on the same IP where Home Assistant is running, use AdGuard Home and its feature DNS rewrites.
Usage of rplb:
-a string
Algorithm used for loadbalancing. Choose from: first, random, roundrobin, sticky or leastloaded. (default "sticky")
-b string
Comma-separated list of BackendPool Name and URL pairs. (example "backend,http://10.0.0.1:1234")
-f string
Comma-separated list of Frontend Hostname and BackendPool Name pairs. (example "frontend.example.com,backend")
There is an /example
folder in this repository containing already configured RPLB
with tree backends. You can try it our by running:
docker compose -f example/compose.yaml up rplb --build
for i in {1..10}; do curl -s localhost:8080 | grep \<h1; sleep 1; done;
docker compose -f example/compose.yaml down
docker compose -f example/leastloaded/compose.yaml up rplb --build
seq 1000 | parallel -n0 -j8 "curl -s http://localhost:8080 | grep Response"
docker compose -f example/leastloaded/compose.yaml down
git tag
git tag v0.1
git push origin v0.1
go run -ldflags "-X github.com/dalibormesaric/rplb/internal/config.Version=$(git describe --tags --abbrev=0)" cmd/rplb/main.go
docker build --build-arg="VERSION=$(git describe --tags --abbrev=0)" -t rplb .
go test ./... -count=1
With this project I wanted to have two things:
- A simple way to load balance traffic between bare metal kubernetes cluster nodes
- A fun Go project to work on
Read more on Load Balancing and Reverse Proxy
- docs
- algorithm state expiration?
- favicon on static pages?