Hi, Why bother with the complex vcl_hit? Since you are saying that the cache is regularly primed, I don't really see the added value.
(note, after a quick glance at it, I think it could just be a race condition where the backend appears up in vcl_hit and is down by the time you ask it the content) -- Guillaume Quintard On Wed, Nov 15, 2017 at 6:02 AM, Andrei <[email protected]> wrote: > bump > > On Sun, Nov 5, 2017 at 2:12 AM, Andrei <[email protected]> wrote: > >> Hello everyone, >> >> One of the backends we have configured, runs through an SSH tunnel which >> occasionally gets restarted. When the tunnel is restarted, Varnish is >> returning a 503 since it can't reach the backend for pages which would >> normally be cached (we force cache on the front page of the related site). >> I believe our grace implementation might be incorrect, as we would expect a >> grace period cache return instead of 503. >> >> Our grace ttl is set to 21600 seconds based on a global variable: >> >> sub vcl_backend_response { >> set beresp.grace = std.duration(variable.global_get("ttl_grace") + >> "s", 6h); >> } >> >> Our grace implementation in sub vcl_hit is: >> >> sub vcl_hit { >> # We have no fresh fish. Lets look at the stale ones. >> if (std.healthy(req.backend_hint)) { >> # Backend is healthy. Limit age to 10s. >> if (obj.ttl + 10s > 0s) { >> #set req.http.grace = "normal(limited)"; >> std.log("OKHITDELIVER: obj.ttl:" + obj.ttl + " obj.keep: " + >> obj.keep + " obj.grace: " + obj.grace); >> return (deliver); >> } else { >> # No candidate for grace. Fetch a fresh object. >> std.log("No candidate for grace. Fetch a fresh object. obj.ttl:" >> + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace); >> return(miss); >> } >> } else { >> # backend is sick - use full grace >> if (obj.ttl + obj.grace > 0s) { >> #set req.http.grace = "full"; >> std.log("SICK DELIVERY: obj.hits: " + obj.hits + " obj.ttl:" + >> obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace); >> return (deliver); >> } else { >> # no graced object. >> std.log("No graced object. obj.ttl:" + obj.ttl + " obj.keep: " + >> obj.keep + " obj.grace: " + obj.grace); >> return (miss); >> } >> } >> >> # fetch & deliver once we get the result >> return (miss); # Dead code, keep as a safeguard >> } >> >> >> Occasionally we see: >> - VCL_Log No candidate for grace. Fetch a fresh object. >> obj.ttl:-1369.659 obj.keep: 0.000 obj.grace: 21600.000 >> >> For the most part, it's: >> - VCL_Log OKHITDELIVER: obj.ttl:26.872 obj.keep: 0.000 >> obj.grace: 21600.000 >> >> Are we setting the grace ttl too low perhaps? >> > > > _______________________________________________ > varnish-misc mailing list > [email protected] > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc >
_______________________________________________ varnish-misc mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
