vcl_error restart
Le Roux Bodenstein
lerouxb at gmail.com
Mon Jun 22 17:05:09 CEST 2009
I'm trying to setup varnish so that it will try one backend and then
if there's an error (for example - the backend isn't up at all - not
even throwing 500 errors), it tries a fallback backend. I'm trying to
get varnish to immediately try another backend if I restart my app. So
the first backend is my django powered web app and the second one is a
smaller, dumb one that just tries to read from a cache that I manage.
I only want to use this cache as a fallback - it isn't a max-age based
thing.
I think backend polling isn't perfect here - I don't want requests to
die for seconds before health polling figures it out - the app will be
restarted within seconds already anyway. I also don't want to use the
grace functionality here - this is only for non-cacheable (not by
varnish, anyway) web app urls that need to be re-evaluated all the
time. (I'm thinking of sending static, cacheable urls to a third
backend - a traditional webserver)
So basically, I want to do something like this:
backend b1 {
.host = "localhost";
.port = "8000";
}
backend b2 {
.host = "localhost";
.port = "8001";
}
sub vcl_recv {
if (req.restarts == 0) {
set req.backend = b1;
} else {
set req.backend = b2;
}
}
sub vcl_error {
if (req.restarts == 0) {
set req.backend = b2;
restart;
}
}
But my second backend never gets a request. Is this possible? Has
anyone done something like this before?
Le Roux
More information about the varnish-misc
mailing list