Saint mode (4.1 or later)

Saint mode ("inferred health probes from traffic") was taken out of Varnish core in 4.0, and is now back as a separate vmod. This is useful for detecting failing backends before the health probes pick it up.

This VMOD provides saintmode functionality for Varnish master branch commit 418cea5 or later and the upcoming 4.1.0 release. The code is in part based on Poul-Henning Kamp's saintmode implementation in Varnish 3.0.

Saintmode lets you deal with a backend that is failing in random ways for specific requests. It maintains a blacklist per backend, marking the backend as sick for specific objects. When the number of objects marked as sick for a backend reaches a set threshold, the backend is considered sick for all requests. Each blacklisted object carries a TTL, which denotes the time it will stay blacklisted.

Saintmode in Varnish 4.1.0 is implemented as a director VMOD. We instantiate a saintmode object and give it a backend as an argument. The resulting object can then be used in place of the backend, with the effect that it also has added saintmode capabilities.


backend b0 {
      .host = "foo";
      .port = "8080";

backend b1 {
      .host = "bar";
      .port = "8080";

sub vcl_init {
      # Instantiate sm0, sm1 for backends b0, b1
      new sm0 = saintmode.saintmode(b0, 10);
      new sm1 = saintmode.saintmode(b1, 10);

      # Add both to a director. Use sm0, sm1 in place of b0, b1
      new mydir = directors.random();
      mydir.add_backend(sm0.backend(), 1);
      mydir.add_backend(sm1.backend(), 1);

sub vcl_backend_fetch {
      set bereq.backend = mydir.backend();

sub vcl_backend_response {
      if (beresp.status == 500) {
              # This marks the backend as sick for this specific
              # object for the next 20s.
              return (retry);



Used in production
Varnish version supported: 
Commercial support: 
Varnish Software