Directors

  Last updated April 01, 2020

Fastly's directors contain a list of backends to direct requests to. Traffic is distributed according to the specific director policy.

Healthcheck probes should be defined for backends within directors so the director can check the backend health state before sending a request. Directors will not send traffic to a backend that is identified as unhealthy.

Random director

The random director selects a backend randomly from the healthy subset of backends.

Each backend has a .weight attribute that indicates the weighted probability of the director selecting the backend.

The random director has the following properties:

In the following example, the random director will randomly select a backend with equal probability. At minimum, two backends must be healthy for their cumulative weight (~ 66%) to exceed the 50% quorum weight and qualify the director as healthy. If only one backend is healthy and the quorum weight is not reached, a "Quorum weight not reached" error will be returned to the client. If the random director fails to connect to the chosen backend, it will retry randomly selecting a backend up to three times before indicating all backends are unhealthy.

1
2
3
4
5
6
7
director my_dir random {
    .quorum = 50%;
    .retries = 3;
    { .backend = F_backend1; .weight = 1; }
    { .backend = F_backend2; .weight = 1; }
    { .backend = F_backend3; .weight = 1; }
}

Fallback director

The fallback director always selects the first healthy backend in its backend list to send requests to. If Varnish fails to establish a connection with the chosen backend, the director will select the next healthy backend.

In the following example, the fallback director will send requests to F_backend1 until its health status is unhealthy. If the Varnish client is unable to connect to F_backend1 (e.g., a 503 connection timed out response is returned), the fallback director will select the next healthy backend. If all backends in the list are unhealthy or all backends fail to accept connections, a 503 all backends failed or unhealthy response is returned to the client.

1
2
3
4
5
director my_dir fallback {
  { .backend = F_backend1; }
  { .backend = F_backend2; }
  { .backend = F_backend3; }
}
Back to Top