Kristian Lyngstøl's Blog

Saint mode?

Posted on 2009-07-29

Yet another implementation of saint mode part 3. With some luck, we can do this in trunk soon[tm]. The idea is to let VCL decide, based on the backend response, whether to used a cached object or a fresh one.

This is controlled in VCL ( if(beresp.http.foo == Yes) { set beresp.holdoff = 20s; } ). Not quite ready, but fun nevertheless.

16:56:09 200 OK Age: 0
16:56:10 200 OK Age: 1
16:56:11 200 OK Age: 2
16:56:13 200 OK Age: 4
16:56:14 200 OK Age: 5
16:56:15 200 OK Age: 0
16:56:16 200 OK Age: 1
16:56:17 200 OK Age: 2
16:56:19 200 OK Age: 4
16:56:20 200 OK Age: 5
16:56:21 200 OK Age: 0
16:56:22 200 OK Age: 1
16:56:23 200 OK Age: 2
16:56:25 200 OK Age: 4
16:56:26 200 OK Age: 5
16:56:27 200 OK Age: 0
16:56:28 200 OK Age: 1
16:56:29 200 OK Age: 2
16:56:31 200 OK Age: 4
16:56:32 200 OK Age: 5
16:56:33 200 OK Age: 0
16:56:34 200 OK Age: 1
16:56:35 200 OK Age: 2 <---- Set unwanted header on backend response
16:56:37 200 OK Age: 4
16:56:38 200 OK Age: 5
16:56:39 200 OK Age: 6 <--- 'saint mode' is in effect.
16:56:40 200 OK Age: 7
16:56:42 200 OK Age: 9
16:56:43 200 OK Age: 10
16:56:44 200 OK Age: 11
16:56:45 200 OK Age: 12
16:56:46 200 OK Age: 13
16:56:48 200 OK Age: 14
16:56:49 200 OK Age: 16
16:56:50 200 OK Age: 17
16:56:51 200 OK Age: 18
16:56:52 200 OK Age: 19
16:56:54 200 OK Age: 20 <--- Return backend to normal.
16:56:55 200 OK Age: 22
16:56:56 200 OK Age: 23
16:56:57 200 OK Age: 24
16:56:58 200 OK Age: 25
16:57:00 200 OK Age: 0 <--- Varnish catches up.
16:57:01 200 OK Age: 1
16:57:02 200 OK Age: 2
16:57:03 200 OK Age: 4
16:57:05 200 OK Age: 5
16:57:06 200 OK Age: 0
16:57:07 200 OK Age: 1
16:57:08 200 OK Age: 2
16:57:09 200 OK Age: 4

Btw, this is the output of:

$ while sleep 1; do FOO=`date +%H:%M:%S`; echo -n "$FOO "; GET -Use http://localhost/~kristian/index.cgi | egrep '(^Age|^200|^503)' | perl -e 'while () { chomp; print; print " " }; print "\n"'; done