Ban Expressions and Grace Mode

Rob Worley robert.worley at gmail.com
Thu Apr 12 17:26:12 CEST 2012


I'm using "smart bans" to expire large chunks of cache content. In good
conditions everything works great but I want to serve stale content from
the cache if the backend is down. It appears that Varnish evaluates the ban
before the fetch operation fails, presumably meaning there's nothing left
to serve to the client?

Any advice on handling this requirement, short of adding more backends? At
this stage I'm not even sure that grace works with ban expressions. My VCL
is very similar to this from the Varnish Book but it's not currently
working:

https://www.varnish-software.com/static/book/Saving_a_request.html#example-evil-backend-hack

I read suggestions RE: only accepting ban requests when the backend is
healthy but I don't see how that'll help, given that they are applied "just
in time".

Steps to reproduce:

1. Warm cache using wget or whatever. Response is good and Varnish is
caching as expected.
2. Kill the "normal" backend process.
3. Issue the ban expression (note that ban_lurker_sleep=0).
4. Hit URL with wget again and receive a 503 from Varnish (log output
follows).

TIA for any help/advice,

Rob

3 SessionOpen  c 127.0.0.1 64767 0.0.0.0:8080
3 ReqStart     c 127.0.0.1 64767 1914142754
3 RxRequest    c GET
3 RxURL        c /
3 RxProtocol   c HTTP/1.0
3 RxHeader     c User-Agent: Wget/1.12 (darwin10.6.0)
3 RxHeader     c Accept: */*
3 RxHeader     c Host: xxxx.dev
3 RxHeader     c Connection: Keep-Alive
3 VCL_call     c recv 6 41.3 7 42.5 9 48.5 12 59.3 14 64.3 16 70.3 18 75.3
20 82.3 26 97.3 lookup
3 VCL_call     c hash 1 24.3
3 Hash         c /
3 Hash         c xxxx.dev
3 VCL_return   c hash
3 ExpBan       c 1914142751 was banned
3 VCL_call     c miss 30 110.3 32 113.1 67 99.5 fetch
3 FetchError   c no backend connection
3 VCL_call     c error 47 163.3 48 164.5 restart
3 VCL_call     c recv 6 41.3 8 44.5 10 50.5 12 59.3 14 64.3 16 70.3 18 75.3
20 82.3 26 97.3 lookup
3 VCL_call     c hash 1 24.3
3 Hash         c /
3 Hash         c xxxx.dev
3 VCL_return   c hash
3 VCL_call     c miss 30 110.3 32 113.1 67 99.5 fetch
3 FetchError   c no backend connection
3 VCL_call     c error 47 163.3 49 167.3 deliver
3 VCL_call     c deliver 42 153.3 44 157.3 46 160.1 71 116.5 deliver
3 TxProtocol   c HTTP/1.1
3 TxStatus     c 503
3 TxResponse   c Service Unavailable
3 TxHeader     c Server: Varnish
3 TxHeader     c Content-Type: text/html; charset=utf-8
3 TxHeader     c Retry-After: 30
3 TxHeader     c Content-Length: 383
3 TxHeader     c Accept-Ranges: bytes
3 TxHeader     c Date: Thu, 12 Apr 2012 14:28:03 GMT
3 TxHeader     c X-Varnish: 1914142754
3 TxHeader     c Age: 0
3 TxHeader     c Via: 1.1 varnish
3 TxHeader     c Connection: close
3 Length       c 383
3 ReqEnd       c 1914142754 1334240883.726897955 1334240883.727870941
0.000333071 0.000754118 0.000218868
3 SessionClose c error
3 StatSess     c 127.0.0.1 64767 0 1 1 0 0 0 258 383
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120412/6c04746a/attachment-0001.html>


More information about the varnish-misc mailing list