best node placement for varnish accelaration

Jean-Christian BEDIER jc.bedier at gmail.com
Sun Apr 13 10:35:20 CEST 2014


Hello Tim,

In my opinion your loadbalancer should load balance traffic accross your
varnish's server by using hash uri and backend polling to your varnish's
instance.

Then, your varnish's instance may have to load balance request accorss your
web server.

(step 1 : vip f5) 10.10.40.42 -> (step 2 hash uri backend polling) -> 1
0.10.40.8/10.10.40.8 -> (step 3: backend polling) -> 10.10.40.10/
10.10.40.11/10.10.40.12

Step 2 ensure that /plop will always hit cache on 10.10.40.8 and /plip will
always hit cache on 10.10.40.9
If one of your varnish's server will go down your loadbalancer will just
hit empty cache on other one and remove the failed varnish from vip
10.10.42.42. This method permit build cache on varnish without making
redundancy between them (better web server offload and).

Step 3 avoid reuse f5 LB (except if you need it for rewrite or hash uri for
local cache on your web server), as you know varnish is able to health
check baskend on layer 7.

If i'm unclear feel free to ask.

Regards,


On Sat, Apr 12, 2014 at 10:00 PM, Tim Dunphy <bluethundr at gmail.com> wrote:

> 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
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140413/cfe6e7ac/attachment-0001.html>


More information about the varnish-misc mailing list