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
round-robin(default with--pool) — smooth weighted round-robin across healthy replicas. Set--weight 1..100to send proportionally more requests to larger machines.least-conn— picks the healthy replica with the fewest active in-flight requests (weighted by--weight), ideal for variable-latency APIs and streaming endpoints.ip-hash— hashes the visitor's client IP so repeated requests from the same client stick to the same replica while it stays up.failover— sends all traffic to the primary (highest-weight or earliest) healthy replica and switches to standby replicas immediately if the primary drains or fails.
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
- Every replica joining a pool must present the same owner token (operator token or the member account that owns
--name), matchingproto(http,tcp, ortls), and matching--authcredentials. - Up to 16 replicas may join one pool by default, configurable on the server with
aditd --max-pool-size(ADIT_MAX_POOL_SIZE). - Individual replicas can be inspected and disconnected live from Inspector (
DELETE /api/tunnels/{id}/replicas/{rid}), and/metricsexportsadit_pool_replicas_active,adit_lb_failovers_total, andadit_lb_quarantines_total.