<div dir="ltr">Hi,<div><br></div><div>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.</div><div><br></div><div>(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)</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div>Guillaume Quintard<br></div></div></div>
<br><div class="gmail_quote">On Wed, Nov 15, 2017 at 6:02 AM, Andrei <span dir="ltr"><<a href="mailto:lagged@gmail.com" target="_blank">lagged@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">bump</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 5, 2017 at 2:12 AM, Andrei <span dir="ltr"><<a href="mailto:lagged@gmail.com" target="_blank">lagged@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello everyone,<div><br></div><div>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.</div><div><br></div><div><div>Our grace ttl is set to 21600 seconds based on a global variable:</div><div><br></div><div>sub vcl_backend_response {</div><div> set beresp.grace = std.duration(variable.global_g<wbr>et("ttl_grace") + "s", 6h);</div><div>}</div><div><br></div><div>Our grace implementation in sub vcl_hit is:</div><div><br></div><div> sub vcl_hit {</div><div> # We have no fresh fish. Lets look at the stale ones.</div><div> if (std.healthy(req.backend_hint)<wbr>) {</div><div> # Backend is healthy. Limit age to 10s.</div><div> if (obj.ttl + 10s > 0s) {</div><div> #set req.http.grace = "normal(limited)";</div><div> std.log("OKHITDELIVER: obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (deliver);</div><div> } else {</div><div> # No candidate for grace. Fetch a fresh object.</div><div> std.log("No candidate for grace. Fetch a fresh object. obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return(miss);</div><div> }</div><div> } else {</div><div> # backend is sick - use full grace</div><div> if (obj.ttl + obj.grace > 0s) {</div><div> #set req.http.grace = "full";</div><div> std.log("SICK DELIVERY: obj.hits: " + obj.hits + " obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (deliver);</div><div> } else {</div><div> # no graced object.</div><div> std.log("No graced object. obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (miss);</div><div> }</div><div> }</div><div><br></div><div> # fetch & deliver once we get the result</div><div> return (miss); # Dead code, keep as a safeguard</div><div> }</div><div><br></div><div><br></div><div>Occasionally we see:</div><div>- VCL_Log No candidate for grace. Fetch a fresh object. obj.ttl:-1369.659 obj.keep: 0.000 obj.grace: 21600.000</div><div><br></div><div>For the most part, it's:</div><div>- VCL_Log OKHITDELIVER: obj.ttl:26.872 obj.keep: 0.000 obj.grace: 21600.000</div><div><br></div><div>Are we setting the grace ttl too low perhaps?</div></div></div>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br></blockquote></div><br></div>