Objects in grace while backend is down
Kristian Lyngstol
kristian at redpill-linpro.com
Fri Mar 13 08:10:53 CET 2009
(Added varnish-dev back on CC as this might be of general interest)
On Thu, Mar 12, 2009 at 07:13:01PM -0400, Javier Frias wrote:
> and it would also complain about any use of "obj.*" in vcl_fetch.
>
> So I looked at your included test, and say that you used "beresp.grace"
Yes, obj is no longer available in vcl_fetch, instead, beresp has
essentially replaced it.
> sub vcl_fetch {
> set beresp.grace = 600m;
> set beresp.ttl = 600s;
> set beresp.cacheable = true;
> }
>
> Doesn't complain about syntax, but also doesn't work when the backend is
> down.
>
> Any suggestions? is beresp.grace the right variable to set?
beresp.grace will work, yes, but you are still affected by req.grace.
Grace-timing works like this: beresp.grace sets the time beyond TTL that an
object will exist in cache and req.grace sets the time beyond TTL that an
object is acceptable to return.
Something like this will set a quasi-dynamic req.grace based on backend
health:
sub vcl_recv {
if (req.backend.healthy) {
set req.grace = 30s;
} else {
set req.grace = 30m;
}
}
sub vcl_fetch {
set beresp.grace = 30m;
set beresp.ttl = 10m;
set beresp.cacheable = true;
}
This VCL will tell varnish to always wait for a fresh object if the backend
is healthy and an object is more than 10 minutes and 30 seconds old. If the
backend is sick, it will deliver the cached object for 10m+30m.
Also keep in mind that this depends on backend health polling.
Hope this clarified things.
--
Kristian Lyngstøl
Redpill Linpro AS
Tlf: +47 21544179
Mob: +47 99014497
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20090313/d4c70f21/attachment-0004.pgp>
More information about the varnish-dev
mailing list