Varnish implicitly hashing backend

Neil Saunders n.j.saunders at gmail.com
Mon Apr 30 13:49:17 CEST 2012


Hi all -

I'm attempting to implement a suggestion provided as a solution to another
question I posted regarding cache warming.

Long story short, I have 6 webservers that I'm pre-warming 60,000 urls via
a script. I had previously been sending each request to each web-server,
but it was suggested that it would be much quicker, and indeed more
elegant, to be able to set a header (X-Cache-Warming in this case) that if
set would cause the web-server to use the next web server as the backend,
until it reached the last web server and it would be fetched via the actual
backend: Goal - Make a single request on the first web server to warm all 6.

The issue I'm seeing is following cache warming the I get cache misses on
actual requests on all web servers except the last in the chain, which
would imply to me that Varnish implicitly hashes the backend name used. A
summary of the VCLused:

On all servers except the "last" in the chain I've defined:

backend system {
    .host = system1.domain.com
    .port=80
}

backend next_web_server {
    .host = "webX.domain.com <http://webx.domain.com/>";
    .port = "80";
}

And have added the following to vcl_recv for all web servers except the
last:

  # On all webservers except the last START
  if (req.http.X-Cache-Warming ~ "true") {
      set req.backend = next_web_server;
      set req.hash_always_miss = true;
      return(lookup);
  }
  # On all webservers except the last END

 set req.backend = system;
}

And have the following vcl_hash:

sub vcl_hash {

  hash_data(req.url);
  hash_data(req.http.host);
  return(hash);
}

Any help would be very much appreciated, even if only a  "yes this is how
it works, no there's no workaround" :)

Cheers,

Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120430/43b3937e/attachment.html>


More information about the varnish-misc mailing list