<div dir="ltr">Hello Tim,<div><br></div><div>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.</div><div><br>
</div><div>Then, your varnish's instance may have to load balance request accorss your web server.</div><div><br></div><div>(step 1 : vip f5) 10.10.40.42 -> (step 2 hash uri backend polling) -> 1<span style="font-family:arial,sans-serif;font-size:13px"><a href="http://0.10.40.8/">0.10.40.8/</a></span>1<span style="font-size:13px;font-family:arial,sans-serif">0.10.40.8 -> (step 3: </span>backend polling) -> <span style="font-family:arial,sans-serif;font-size:13px"><a href="http://10.10.40.10/">10.10.40.10/</a></span><span style="font-family:arial,sans-serif;font-size:13px"><a href="http://10.10.40.11/">10.10.40.11/</a></span><span style="font-family:arial,sans-serif;font-size:13px">10.10.40.12</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">Step 2 ensure that /plop will always hit cache on </font>1<span style="font-size:13px;font-family:arial,sans-serif">0.10.40.8 and /plip </span><font face="arial, sans-serif">will always hit cache on </font>1<span style="font-size:13px;font-family:arial,sans-serif">0.10.40.9</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif">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).</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">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.</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><font face="arial, sans-serif">If i'm unclear feel free to ask.</font></div><div><font face="arial, sans-serif"><br></font></div><div>
<font face="arial, sans-serif">Regards,</font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 12, 2014 at 10:00 PM, Tim Dunphy <span dir="ltr"><<a href="mailto:bluethundr@gmail.com" target="_blank">bluethundr@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><span class="HOEnZb"><font color="#888888"><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>
</font></span></div></div>
<br>_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br></blockquote></div><br></div>