pick_fleet_server, backed by a parallel health check across every host in core_fleet.
The fleet-routing logic lives in the API service’s fleet route and fleet service.
core_fleet
core_fleet is a list of CXB Core base URLs stored in the system document of system_settings. Adding a host to this list is all that is needed to include it in routing — no code change or restart. It is read by the dialout route, the LiveKit webhook, and the fleet status endpoint.
Health check
Each host is polled atGET {host}/health/fleet (_check_server). A host is healthy only if all of these hold; otherwise it is reported unreachable:
| Check | Requirement |
|---|---|
| Reachable | HTTP 2xx within FLEET_HEALTH_TIMEOUT_SECONDS (20s) |
| Payload | JSON object with status == "ok" |
fleet_max | non-negative int (total capacity) |
fleet_available | non-negative int, <= fleet_max |
fleet_calls | non-negative int (active calls) |
workers | list |
The timeout is deliberately 20s, not 5s.
/health/fleet aggregates all workers over Unix sockets; when workers are mid-call those polls queue and the endpoint can legitimately take 3–6s. A tight timeout was previously marking healthy-but-busy hosts unreachable and excluding them from routing.Best-server selection
- Only healthy hosts with
total_available > 0are candidates. - The host(s) with the highest
total_availablewin; ties are broken withrandom.choice, spreading load across equally-free hosts. Nonemeans no capacity — callers translate this to503(dialout: No healthy fleet server available; webhook: No healthy fleet).
Fleet status endpoint
GET /api/v1/fleet/status (admin) returns the aggregated view used by the dashboard:
| Field | Meaning |
|---|---|
total_capacity | sum of fleet_max over healthy hosts |
active_calls | sum of fleet_calls over healthy hosts |
available | total_capacity - active_calls |
workers[] | per-host {url, status, total_capacity, total_available, worker_calls, workers} |
config_url passthrough
When proxying a dialout, CXB API injects config_url = <its own base URL>/api/v1/config into the request to the chosen fleet host (see SIP dialout). This lets a single shared fleet serve multiple CXB API instances: each call’s config is fetched back from the CXB API that triggered it, rather than from a fleet-wide environment default.
Related docs
SIP dialout
Where
pick_fleet_server and config_url are used for outbound.LiveKit webhook
Where
pick_fleet_server is used for inbound.Carriers & trunks
The SIP side of the telephony stack.
Settings
Where
core_fleet lives in system settings.