Dual server Varnish setup

Laurence Rowe l at lrowe.co.uk
Thu Feb 10 14:46:40 CET 2011


On 8 February 2011 23:05, Ben Dodd <B.Dodd at comicrelief.com> wrote:
> Given this functionality, does anyone know what the VCL is required to implement this dual server Varnish setup scenario?
> http://varnish-cache.org/trac/wiki/VCLExampleHashIgnoreBusy

Something like this should work:


backend appserver { ... }
backend other_varnish { ... }

# Server 1
sub vcl_recv {
    set req.backend = other_varnish;
    if (req.http.X-Via-Varnish || !req.backend.healthy) {
        # Request is coming from the other server.
        # Ignore busy objects to avoid race condition.
        set req.hash_ignore_busy = 1;
        set req.backend = appserver;
    } else {
        set req.http.X-Via-Varnish = "true";
    }
}

# Server 2
sub vcl_recv {
    set req.backend = other_varnish;
    if (req.http.X-Via-Varnish || !req.backend.healthy) {
        # Request is coming from the other server.
        set req.backend = appserver;
    } else {
        set req.http.X-Via-Varnish = "true";
    }
}

Laurence




More information about the varnish-misc mailing list