Load balancing & endpoint pooling

Endpoint pooling lets two or more tunl agents share one reserved name, custom domain, or TCP/TLS port at the same time. Visitors reach one address while aditd balances traffic across healthy replicas and fails over automatically during restarts.

Pool two or more replicas

Pass --pool or choose a load-balancing mode with --lb on every agent that joins the same --name:

# Replica 1 (machine A or local port 3001)
tunl http 3001 --name api --pool --lb least-conn

# Replica 2 (machine B or local port 3002)
tunl http 3002 --name api --pool --lb least-conn

Without --pool or --lb, a tunnel name stays exclusive so a second agent started by mistake cannot split traffic.

Load-balancing modes

Zero-downtime deploys & circuit breaking

When a pooled agent receives Ctrl+C or SIGTERM, it sends a drain frame first. aditd immediately stops sending new requests to that replica while in-flight requests finish up to --drain-timeout (default 5s).

If a replica's connection drops or its local port refuses a connection before headers are sent, aditd places that replica in a 3-second passive quarantine and retries idempotent requests on a healthy sibling replica without returning 502.

Multi-replica tunl.yml

server: tls://51.83.193.202:7000
tunnels:
  api_blue:
    name: api
    proto: http
    addr: 3001
    pool: true
    lb: least-conn
    weight: 2
    drain_timeout: 10s
  api_green:
    name: api
    proto: http
    addr: 3002
    pool: true
    lb: least-conn
    weight: 1

Security & limits