best node placement for varnish accelaration

Tim Dunphy bluethundr at gmail.com
Sat Apr 12 22:00:30 CEST 2014


Hello list,

 I'm writing to you today about a job I've been asked to do which utilizes
varnish and memcached to accelerate the site.

 I just realized something about the way that my colleague set this up that
makes me question whether the site will actually benefit from ANY
acceleration. My guess is no, but I'd like to see what you think and maybe
have someone offer suggestions for optimal host placement on the network.

 We have an F5 load balancer creating a vip which points to 3 web servers.
Let's say the VIP in question is 10.10.40.42 for illustration purposes.

 The traffic hits the vip on the load balancer and gets distributed to the
3 web servers in the VIP pool. Let's say the web servers are 10.10.40.10,
.11 and .12.

 However on the same subnet as the web servers and not being referenced by
the load balancer is our Varnish / Memcached nodes. We have two cache nodes
running both varnish and memcached at 10.10.40.8 and 10.10.40.9.

 So if the load balancer is handling all the traffic into the site and the
caching hosts are not referenced in the load balancer, don't things need to
be structured differently in order for the site to benefit from the
acceleration they are trying to use?

 For instance, don't the caching nodes need to intercept the vip address
(10.10.40.42) and pass the vip traffic onto the load balancer and have the
load balancer distribute the load in a round robin fashion to the web
servers?  Or maybe the load balancer can just intercept the VIP
(10.10.40.42) and load balance the two caching nodes as its back end and
have the varnish setup round robin the web servers?

Our current setup is similar to the second option above, except the load
balancer is looking at the web servers as it's back end and not the varnish
hosts.

In our current default.vcl we have this:

backend web1 {
    .host = "10.10.40.42";
    .port = "80";
    .connect_timeout = 30s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 70;
    .probe = {
        .url = "/healthcheck.php";
        .timeout = 5s;
        .interval = 30s;
        .window = 10;
        .threshold = 1;
    }
}

backend web2 {
    .host = "10.10.40.10";
    .port = "80";
    .connect_timeout = 30s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 70;
    .probe = {
        .url = "/healthcheck.php";
        .timeout = 5s;
        .interval = 30s;
        .window = 10;
        .threshold = 1;
    }
}

backend web2 {
    .host = "10.10.40.11";
    .port = "80";
    .connect_timeout = 30s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 70;
    .probe = {
        .url = "/healthcheck.php";
        .timeout = 5s;
        .interval = 30s;
        .window = 10;
        .threshold = 1;
    }
}

backend web3 {
    .host = "10.10.40.12";
    .port = "80";
    .connect_timeout = 30s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 70;
    .probe = {
        .url = "/healthcheck.php";
        .timeout = 5s;
        .interval = 30s;
        .window = 10;
        .threshold = 1;
    }
}


backend varnish1 {
    .host = "10.10.40.8";
    .port = "80";
    .connect_timeout = 5s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 1000;
}


backend varnish2 {
    .host = "10.10.40.9";
    .port = "80";
    .connect_timeout = 5s;
    .first_byte_timeout = 30s;
    .between_bytes_timeout = 30s;
    .max_connections = 1000;
}


acl purge {
    "localhost";
    "127.0.0.1";
    "10.10.40.8";
    "10.10.40.9";
}

director www round-robin {
    { .backend = web1; }
    { .backend = web2; }
    { .backend = web3; }
}

director cache round-robin {
    { .backend = varnish1; }
    { .backend = varnish2; }
}


if (req.restarts == 0) {
        if (client.ip == "10.10.40.8" || client.ip == "10.10.40.9") {
            set req.backend = www;
        } elsif (server.ip == "10.10.40.8") {
            set req.backend = varnish2;
        } else {
            set req.backend = varnish1;
        }
    } elsif (req.restarts >= 2) {
        return (pass);



There's actually a bit more to that vcl file. However I believe that what
I've just presented to you are the most salient parts that will illustrate
what we're doing, here.


Also in the config I've inherited, that last stanza (if (req.restarts=0))
 is the same on both varnish nodes. Would you want to vary that stanza so
that it would say this on the second varnish node:

 if (client.ip == "10.10.40.8" || client.ip == "10.10.40.9") {
            set req.backend = www;
        } elsif (server.ip == "10.10.40.9") {
            set req.backend = varnish1;
        } else {
            set req.backend = varnish2;
        }

And to be honest I'm not really clear on the purpose of this section. If
someone could enlighten me on that point that'd be great!

Thanks in advance,
Tim

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140412/777c2c0f/attachment.html>


More information about the varnish-misc mailing list