Varnish still 503ing after adding grace to VCL

Drew Smathers drew.smathers at gmail.com
Mon Mar 7 21:58:15 CET 2011


Hi all,

I'm trying to grace as a means of ensuring that cached content is
delivered from varnish past it's TTL if backends can't generate a
response. With some experiments this does not seem to happen with our
setup. After an object is cached, varnish still returns a 503 within
the grace period if a backend goes down. Below are details.

version: varnish-2.1.4 SVN 5447M

I stripped down my VCL to the following to demonstrate:

backend webapp {
    .host = "127.0.0.1";
    .port = "8000";
}

sub vcl_recv {
   set req.backend = webapp;
   set req.grace = 1h;
}


sub vcl_fetch {
   set beresp.grace = 24h;
}

Running varnish:

varnishd -f simple.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080


First request:

GET /some/path/ HTTP/1.1
Accept-Language: en

HTTP/1.1 200 OK
Server: WSGIServer/0.1 Python/2.6.6
Vary: Authorization, Accept-Language, X-Gttv-Apikey
Etag: "e9c12380818a05ed40ae7df4dad67751"
Content-Type: application/json; charset=utf-8
Content-Language: en
Cache-Control: max-age=30
Content-Length: 425
Date: Mon, 07 Mar 2011 16:12:56 GMT
X-Varnish: 377135316 377135314
Age: 6
Via: 1.1 varnish
Connection: close


Wait 30 seconds, kill backend app, then make another request through varnish:

GET /some/path/ HTTP/1.1
Accept-Language: en

HTTP/1.1 503 Service Unavailable
Server: Varnish
Retry-After: 0
Content-Type: text/html; charset=utf-8
Content-Length: 418
Date: Mon, 07 Mar 2011 16:14:02 GMT
X-Varnish: 377135317
Age: 0
Via: 1.1 varnish
Connection: close

Any help or clarification on request grace would be appreciated.

Thanks,
-Drew




More information about the varnish-misc mailing list