# Health checks and balancing

**Probe types** (endpoint `probe`):

| Probe | What it does | Up when |
|---|---|---|
| `tcp` (default) | connects (and on a `backend_tls` endpoint completes the TLS handshake) | the connect (and handshake) succeeds |
| `http` | `GET probe_url` (default `http://<host>:<port>/`, or `https://…` with `backend_tls`), no redirects | status 200–399 |
| `crushftp` | logs in at `probe_url` as `probe_user` and reads CrushMFT's metrics | the login and metrics work; see "up with warning" |
| `none` | no active check (the default on range listeners) | — (only passive detection) |

- **Timing:** every `ping_interval` seconds (default 10), each run limited to `probe_timeout` (default 5 s). Two good runs bring a DOWN endpoint UP; three failed runs take an UP endpoint DOWN; the first result decides for a new endpoint (which starts UNKNOWN and gets traffic).
- **Passive detection:** three connection failures in a row mark an endpoint DOWN at once. With an active probe, only the probe brings it back (two good runs); with `probe=none` it gets traffic again 30 seconds later.
- A DOWN endpoint gets no new connections; open sessions are never closed by a health change.
- **"Up, with warning"**: the endpoint is reachable and stays routable, but something short of a failure went wrong, and the message says what:
  - a `crushftp` probe could not log in, CrushMFT reported a licence problem, or the metrics had an unexpected format: no metrics are read;
  - the certificate of an `https` probe URL that is not checked with the endpoint's own trust settings (any URL on an endpoint without `backend_tls`, or a URL on another host or port) failed the Java trust store or the host-name check: **no credentials are sent** to it, and no metrics are read.
- **On `backend_tls` endpoints**, probes of the endpoint's own host and port use the endpoint's trust settings (the pin, or the trust store with the host-name check). An untrusted certificate is **DOWN**, with "certificate not trusted (SHA-256 …)", because real connections would fail the same way.
- **Check now** in the endpoint dialog runs the probe at once.

**Balancing** (listener `algorithm`):
- `least_conn` (default): the fewest open connections per unit of `weight`.
- `round_robin`: smooth weighted round robin.
- `metric`: `least_conn` among the endpoints whose CrushMFT metric (listener `metric`, default `server_cpu`) is within max(5, 10 %) of the lowest. It needs `probe=crushftp` endpoints; otherwise it behaves as `least_conn` (warning METRIC_NO_SOURCE). A metric is used for 3 × `ping_interval` after it was read.
- A pinned client (cookie or address pin) goes to its backend while that backend is eligible.
- Endpoint `max_connections` (0 = unlimited) is enforced exactly; a full endpoint is skipped.
- A connection attempt waits at most 5 s (plus 10 s for the TLS handshake with `backend_tls`) and is tried on up to 3 endpoints (on range listeners only once).
