vcl_error restart

Le Roux Bodenstein lerouxb at gmail.com
Tue Jun 23 10:46:09 CEST 2009


> I investigated doing something similar with Varnish a little while ago
> when the backend health checks were first included. I decided at the time
> that it couldn't achieve what I wanted, so I left that functionality
> inside the Pound config one layer down. The way we do this is with Pound's
> HAPort directive plus its Emergency Backend.

Thank you. I will certainly investigate Pound. My main concern is just
all the hops and movable parts, but I guess that's what benchmarking
is for.

I eventually figured out yesterday that the main reason my config
didn't work is because I misinterpreted max-restarts. I thought 4 was
a bit much in this case, so I set it to one thinking that one restart
means it will restart once, but it turns out that means it won't
restart at all. When I set that to 2 it started working.

I also did some more thinking and my backend is actually a webserver
(lighttpd) that handles the static files and sends the dynamic
requests on to django. So if the django server is gone it already
returns a 503 which is easy enough to work with in vcl. I almost never
restart lighttpd (in years I restarted it once to enable ssl) so
that's pretty stable. I want lighttpd to continue to serve up the
static files even when I'm on the "emergency backend", so I don't know
if backend monitoring is going to work easily for me. When the django
server goes down it is only seconds, so I still think health
monitoring and status is a bit overkill for me at this stage, so I'll
see how this works out. I'm hoping it will fallback immediately and
start using the primary backend as soon as it is up again.

I will write up my config/setup if/once I get this working.


But basically my config is now:

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_fetch {
    if (obj.status >= 500) {
        restart;
    }
}

sub vcl_error {
   if (req.restarts == 0) {
       restart;
   }
}

And I set max_restarts to 2 elsewhere.



More information about the varnish-misc mailing list