<div dir="ltr">Hello list,<div><br></div><div> I'm writing to you today about a job I've been asked to do which utilizes varnish and memcached to accelerate the site. </div><div><br></div><div> 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.</div>
<div><br></div><div> 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. </div><div><br></div><div> 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.</div>
<div><br></div><div> 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.</div>
<div><br></div><div> 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? </div>
<div>  </div><div> 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?</div>
<div><br></div><div>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.</div><div><br></div><div>In our current default.vcl we have this:</div>
<div><br></div><div><div>backend web1 {</div><div>    .host = "10.10.40.42";</div><div>    .port = "80";</div><div>    .connect_timeout = 30s;</div><div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div>
<div>    .max_connections = 70;</div><div>    .probe = {</div><div>        .url = "/healthcheck.php";</div><div>        .timeout = 5s;</div><div>        .interval = 30s;</div><div>        .window = 10;</div><div>
        .threshold = 1;</div><div>    }</div><div>}</div></div><div><br></div><div><div>backend web2 {</div><div>    .host = "10.10.40.10";</div><div>    .port = "80";</div><div>    .connect_timeout = 30s;</div>
<div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div><div>    .max_connections = 70;</div><div>    .probe = {</div><div>        .url = "/healthcheck.php";</div><div>        .timeout = 5s;</div>
<div>        .interval = 30s;</div><div>        .window = 10;</div><div>        .threshold = 1;</div><div>    }</div><div>}</div></div><div><br></div><div><div>backend web2 {</div><div>    .host = "10.10.40.11";</div>
<div>    .port = "80";</div><div>    .connect_timeout = 30s;</div><div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div><div>    .max_connections = 70;</div><div>    .probe = {</div>
<div>        .url = "/healthcheck.php";</div><div>        .timeout = 5s;</div><div>        .interval = 30s;</div><div>        .window = 10;</div><div>        .threshold = 1;</div><div>    }</div><div>}</div></div>
<div><br></div><div><div>backend web3 {</div><div>    .host = "10.10.40.12";</div><div>    .port = "80";</div><div>    .connect_timeout = 30s;</div><div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div>
<div>    .max_connections = 70;</div><div>    .probe = {</div><div>        .url = "/healthcheck.php";</div><div>        .timeout = 5s;</div><div>        .interval = 30s;</div><div>        .window = 10;</div><div>
        .threshold = 1;</div><div>    }</div><div>}</div></div><div><br></div><div><br></div><div><div>backend varnish1 {</div><div>    .host = "10.10.40.8";</div><div>    .port = "80";</div><div>    .connect_timeout = 5s;</div>
<div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div><div>    .max_connections = 1000;</div><div>}</div></div><div><br></div><div><br></div><div><div>backend varnish2 {</div><div>    .host = "10.10.40.9";</div>
<div>    .port = "80";</div><div>    .connect_timeout = 5s;</div><div>    .first_byte_timeout = 30s;</div><div>    .between_bytes_timeout = 30s;</div><div>    .max_connections = 1000;</div><div>}</div></div><div>
<br></div><div><br></div><div><div>acl purge {</div><div>    "localhost";</div><div>    "127.0.0.1";</div><div>    "10.10.40.8";</div><div>    "10.10.40.9";</div><div>}</div></div><div>
<br></div><div><div>director www round-robin {</div><div>    { .backend = web1; }</div><div>    { .backend = web2; }</div><div>    { .backend = web3; }</div><div>}</div></div><div><br></div><div><div>director cache round-robin {</div>
<div>    { .backend = varnish1; }</div><div>    { .backend = varnish2; }</div><div>}</div></div><div><br></div><div><br></div><div><div>if (req.restarts == 0) {</div><div>        if (client.ip == "10.10.40.8" || client.ip == "10.10.40.9") {</div>
<div>            set req.backend = www;</div><div>        } elsif (server.ip == "10.10.40.8") {</div><div>            set req.backend = varnish2;</div><div>        } else {</div><div>            set req.backend = varnish1;</div>
<div>        }</div><div>    } elsif (req.restarts >= 2) {</div><div>        return (pass);</div></div><div><div><br></div><div><br></div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div>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:</div>
<div><br></div><div><div> if (client.ip == "10.10.40.8" || client.ip == "10.10.40.9") {</div><div>            set req.backend = www;</div><div>        } elsif (server.ip == "10.10.40.9") {</div>
<div>            set req.backend = varnish1;</div><div>        } else {</div><div>            set req.backend = varnish2;</div><div>        }</div></div><div><br></div><div>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!</div>
<div><br></div><div>Thanks in advance,</div><div>Tim</div><div><br></div>-- <br>GPG me!!<br><br>gpg --keyserver <a href="http://pool.sks-keyservers.net" target="_blank">pool.sks-keyservers.net</a> --recv-keys F186197B<br>
<br>
</div></div>