Varnish still 503ing after adding grace to VCL
Adam Denenberg
adam at dberg.org
Thu Apr 28 04:03:57 CEST 2011
Just re-surfacing an old thread. Could you do this another way by creating
a director of both the real backend and "failapp". Then, when you restart
you should be out of backend choices, no ?
On Tue, Mar 8, 2011 at 7:23 PM, Drew Smathers <drew.smathers at gmail.com>wrote:
> On Tue, Mar 8, 2011 at 3:51 PM, Per Buer <perbu at varnish-software.com>
> wrote:
> > Hi Drew, list.
> > On Tue, Mar 8, 2011 at 9:34 PM, Drew Smathers <drew.smathers at gmail.com>
> > wrote:
> >>
> >> Sorry to bump my own thread, but does anyone know of a way to set
> >> saintmode if a backend is down, vs. up and misbehaving (returning 500,
> >> etc)?
> >>
> >> Also, I added a backend probe and this indeed caused grace to kick in
> >> once the probe determined the backend as sick.I think the docs should
> >> be clarified if this isn't a bug (grace not working without probe):
> >>
> >>
> http://www.varnish-cache.org/docs/2.1/tutorial/handling_misbehaving_servers.html#tutorial-handling-misbehaving-servers
> >
> > Check out the trunk version of the docs. Committed some earlier today.
> >
>
> Thanks, I see a lot is getting
>
> >>
> >> Finally it's somewhat disconcerting that in the interim between a
> >> cache expiry and before varnish determines a backend as down (sick) it
> >> will 503 - so this could affect many clients during that window.
> >> Ideally, I'd like to successfully service requests if there's an
> >> object in the cache - period - but I guess this isn't possible now
> >> with varnish?
> >
> > Actually it is. In the docs there is a somewhat dirty trick where set a
> > marker in vcl_error, restart and pick up on the error and switch backend
> to
> > one that is permanetly down. Grace kicks in and serves the stale content.
> > Sometime post 3.0 there will be a refactoring of the whole vcl_error
> > handling and we'll end up with something a bit more elegant.
> >
>
> Well a dirty trick is good enough if makes a paying customer for me. :P
>
> This is working perfectly now. I would suggest giving an example of
> "magic marker" mentioned in the document which mentions the trick
> (
> http://www.varnish-cache.org/docs/trunk/tutorial/handling_misbehaving_servers.html
> ).
> Here's a stripped down version of my VCL incorporating the trick:
>
> backend webapp {
> .host = "127.0.0.1";
> .port = "8000";
> .probe = {
> .url = "/hello/";
> .interval = 5s;
> .timeout = 1s;
> .window = 5;
> .threshold = 3;
> }
> }
>
> /* A backend that will always fail. */
> backend failapp {
> .host = "127.0.0.1";
> .port = "9000";
> .probe = {
> .url = "/hello/";
> .interval = 12h;
> .timeout = 1s;
> .window = 1;
> .threshold = 1;
> }
> }
>
> sub vcl_recv {
>
> if (req.http.X-Varnish-Error == "1") {
> set req.backend = failapp;
> unset req.http.X-Varnish-Error;
> } else {
> set req.backend = webapp;
> }
>
> if (! req.backend.healthy) {
> set req.grace = 24h;
> } else {
> set req.grace = 1m;
> }
> }
>
> sub vcl_error {
> if ( req.http.X-Varnish-Error != "1" ) {
> set req.http.X-Varnish-Error = "1";
> return (restart);
> }
>
> }
>
> sub vcl_fetch {
> set beresp.grace = 24h;
> }
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110427/31a479c2/attachment.html>
More information about the varnish-misc
mailing list