Varnish and time out on backend (first_byte_timeout).
Kristian Lyngstol
kristian at varnish-software.com
Wed Jan 12 14:31:58 CET 2011
On Wed, Jan 12, 2011 at 11:34:37AM +0100, Mickaël GERVAIS wrote:
> If a timeout occurs (first_byte_timeout reached) the function vcl_error is
> called, I'd like to use the saint mode to retreive the response from the
> cache, but saint mode is only avaliable on beresp.
>
> Is there a way to tell varnish use a dirty object from the cache? Maybe is
> not the correct way to handle this kind of error.
You are correct - that is a weakness. I have a nasty hack, though.
1. Declare a second, bogus backend which will always be sick.
2. In vcl_error if restarts is 0, set a magic marker and restart.
3. Look for the magic marker in vcl_recv - if it's present, tell Varnish to
use the bogus backend. Grace will then kick in because that backend is
marked as sick.
4. If the object exists in cache (graced) - it will be used. Otherwise, you
will hit vcl_error again. (Thus the check of req.restarts in step 2).
It's a nasty, yet brilliant hack, if I might say so myself ;)
It adds latency and doesn't utilize saintmode, but it gets the job done in
a way that will also make little children cry.
- Kristian
More information about the varnish-misc
mailing list