genlb - connection load balancer for Unix processes
genlb [-c strategy|-v] command arg ...
genlb
monitors a subprocess, intercepting calls to connect(2)
using
ptrace(2)
.
If the destination of the connect(2)
matches an IP address/port,
genlb
probes a list of IP addresses and rewrites the connect(2)
in the subprocess to use the first working IP.
genlb
uses the libglb LD_PRELOAD
library for the connect(2)
load balancing.
## Create 2 test listeners
# shell 1
nc -vvv -k -l 127.3.0.1 8000
# shell 2
nc -vvv -k -l 127.3.0.2 8000
## Load balanced client
LD_PRELOAD=libglb.so \
GLB_OPTIONS="--random 127.0.0.1:8000 127.3.0.1 127.3.0.2" \
genlb nc -vvv 127.0.0.1 8000
LD_PRELOAD=libglb.so : Set path to libglb
GLB_OPTIONS : See https://github.com/msantos/genlb/blob/master/README.md
-c, --connect-failure exit|continue
: Behaviour on connect(2)
failure
-v, --verbose : Enable debug messages
make