PURGING objects on multiple instances of varnish
Puneet
puneet.arora at insticator.com
Wed May 29 20:45:18 CEST 2013
Yes, that make sense.
Thanks
Puneet
From: Stephen Wood [mailto:smwood4 at gmail.com]
Sent: Wednesday, May 29, 2013 2:35 PM
To: Puneet
Cc: varnish-misc at varnish-cache.org
Subject: Re: PURGING objects on multiple instances of varnish
So somebody more skilled than myself might be able to offer a better
example, but I believe a multi-varnish reverse-proxy setup requires two
layers, which I'll call a "frontend" and "backend". These are two separate
varnish processes running on different ports.
Your frontend.vcl has knowledge of every one of your varnish caching
server's backend processes, and is set to use the hash director. It doesn't
do any caching and has no knowledge of a purge. Your backend.vcl contains
information on the web server you are acting as a reverse proxy against and
does all of the caching.
Request go from your LB to your frontend on any varnish server, it doesn't
matter which one. The request is then hashed to a single one of your varnish
servers's backends. The backend process can be on the server itself, or on
another server in the cluster. If it's a hit, that server serves it up. If
it's a miss it goes to your backend.
Does this make sense? I'm certainly not an expert on this. The idea is that
the object is only stored once on your cluster, and any request to purge it
will only get sent to the server that might have it in its cache.
Good luck.
On Wed, May 29, 2013 at 11:00 AM, Puneet <puneet.arora at insticator.com
<mailto:puneet.arora at insticator.com> > wrote:
Hi,
The VCL subroutines are following:
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return(lookup);
}
//// rest of the code
}
sub vcl_miss {
##purge content from cache only via localhost
if (req.request == "PURGE") {
purge;
error 404 "Not in cache.";
}
return (fetch);
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (deliver);
}
sub vcl_hash {
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (hash);
}
Thanks
Puneet
From: Stephen Wood [mailto:smwood4 at gmail.com <mailto:smwood4 at gmail.com> ]
Sent: Wednesday, May 29, 2013 1:32 PM
To: Puneet
Cc: varnish-misc at varnish-cache.org <mailto:varnish-misc at varnish-cache.org>
Subject: Re: PURGING objects on multiple instances of varnish
What does your VCL look like?
On Wed, May 29, 2013 at 9:50 AM, Puneet <puneet.arora at insticator.com
<mailto:puneet.arora at insticator.com> > wrote:
Hi Stephen,
Yes the Varnish will use hash_director.
The Load Banalcer is executing in Round Robin manner. The LB is connected to
4 instances of Varnish which will be given requests in Round Robin fashion.
Now, in order to send the request to Varnish directly, I need the host to be
the IP & Port of the varnish instances.
i.e. let I have ONE varnish instance at 192.168.0.23 at port 3002
so the request will be for " -XPURGE http://192.168.0.23:3002/
<http://192.168.0.23:3002/%3cpath-to-object> <path-to-object> "
By, doing that Varnish gives a response stating "405 Object Not in Cache"
Thanks
Puneet
From: Stephen Wood [mailto:smwood4 at gmail.com <mailto:smwood4 at gmail.com> ]
Sent: Tuesday, May 28, 2013 5:42 PM
To: Puneet
Cc: varnish-misc at varnish-cache.org <mailto:varnish-misc at varnish-cache.org>
Subject: Re: PURGING objects on multiple instances of varnish
Generally speaking, the varnish setup you are describing would use a hash
director and not round-robin, so that the object would only be cached on one
of your varnish nodes and therefore only require a single purge request.
If your object lives on multiple nodes, then you could do something simple
like send a HTTP request to every one of your hosts. This would require you
to keep a list of your hosts and also create the appropriate permissions on
all of your varnish instances:
$ for i in `cat varnish_host.list`; do curl -XPURGE <http://$i/object;done>
http://$i/object;done
I hope that helps. Maybe somebody can offer a better solution than myself.
On Tue, May 28, 2013 at 2:17 PM, Puneet <puneet.arora at insticator.com
<mailto:puneet.arora at insticator.com> > wrote:
Hi All,
I am using a Load Balancer (LB) in front of Varnish instances. Just say the
LB is listening on Port: 80 and there are multiple instances of Varnish on
different port nos.
i.e. I have a single LB which is connected to 4 instances of varnish, and LB
is executing in a round-robin fashion.
Now, how can I purge objects on Varnish and maintain consistency among
different instances of Varnish.
Thanks
Puneet
_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org <mailto: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/20130529/514eb78c/attachment-0001.html>
More information about the varnish-misc
mailing list