7. THE ENRISE RESTAURANT
∂ We want to prepare the best dishes
∂ With the best ingredients
∂ To create a magical client experience!
∂ Engineers are our top chefs!
3
23. WHAT IS VARNISH? (2)
∂ Originally built for a Norwegian newspaper
11
24. WHAT IS VARNISH? (2)
∂ Originally built for a Norwegian newspaper
∂ > 545k new hostnames in December 2010
§ NetCraft monthly survey
11
25. WHAT IS VARNISH? (2)
∂ Originally built for a Norwegian newspaper
∂ > 545k new hostnames in December 2010
§ NetCraft monthly survey
∂ Known users
§ Wikileaks
§ Facebook
§ Twitter
§ SlashDot
∂ Massive growth in usage
11
27. WHAT IS VARNISH? (3)
∂ Designed for 64bit architecture
∂ Scaling limitations currently unknown
12
28. WHAT IS VARNISH? (3)
∂ Designed for 64bit architecture
∂ Highly scalable
∂ Scaling limitations currently unknown
12
29. WHAT IS VARNISH? (3)
∂ Designed for 64bit architecture
∂ Highly scalable
§Varnish in front of Varnish(es)
∂ Scaling limitations currently unknown
12
30. WHAT IS VARNISH? (3)
∂ Designed for 64bit architecture
∂ Highly scalable
§Varnish in front of Varnish(es)
∂ Perfect browser cache solution
∂ Scaling limitations currently unknown
12
31. WHAT IS VARNISH? (3)
∂ Designed for 64bit architecture
∂ Highly scalable
§Varnish in front of Varnish(es)
∂ Perfect browser cache solution
§Prevent those hard refresh calls!
∂ Scaling limitations currently unknown
12
40. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Compiled to C when run
19
41. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Compiled to C when run
19
42. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Access control lists
∂ Compiled to C when run
19
43. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Access control lists
∂ Saint and grace mode
∂ Compiled to C when run
19
44. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Access control lists
∂ Saint and grace mode
∂ Custom subroutines
∂ Compiled to C when run
19
45. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Access control lists
∂ Saint and grace mode
∂ Custom subroutines
∂ Inline C
∂ Compiled to C when run
19
46. VARNISH CONFIGURATION LANGUAGE (1)
∂ 11 subroutines (vcl_recv, vcl_hash, etc ...)
∂ Backend(s)
∂ Directors (random, round robin, hash)
∂ Access control lists
∂ Saint and grace mode
∂ Custom subroutines
∂ Inline C
∂ Since v3.0 : VMODS
∂ Compiled to C when run
19
47. VARNISH CONFIGURATION LANGUAGE (2)
if (req.request == “GET” &&
req.url ~ “.(gif|jpg|jpeg|bmp|png|ico)$”) {
unset req.http.cookie;
set req.grace = 1m;
return(lookup);
}
∂ Cache images in vcl_recv
20
48. VARNISH CONFIGURATION LANGUAGE (3)
if (req.http.cookie) {
set req.http.Cookie = regsuball(req.http.Cookie,
"__utm.=[^;]+(; )?", "");
if (req.http.cookie ~ "^ *$") {
remove req.http.cookie;
}
}
∂ Remove Google Analytics in vcl_recv
21
51. VARNISH CONFIGURATION LANGUAGE (6)
if (obj.hits > 0) {
#if hit add hit count
set resp.http.X-Cache = "HIT-" obj.hits;
} else {
set resp.http.X-Cache = "MISS”;
}
∂ Adding headers on response
24
63. VARNISHING WORDPRESS (4)
# Drop any cookies sent to WordPress.
sub vcl_recv {
unset req.http.cookie;
}
# Drop any cookies WordPress tries to send back
sub vcl_fetch {
unset beresp.http.set-cookie;
}
∂ Kill those cookies!!
28
71. EDGE SIDE INCLUDES (1)
∂ Markup language
∂ Co-authored Akamai, IBM, Oracle & more
∂ Extensive features
∂ Very powerful for content assembly
31
72. EDGE SIDE INCLUDES (2)
∂ if ... else
§ <esi:choose><esi:when> ... <esi:otherwise>
∂ Variables
§ <esi:assign> and <esi:vars>
∂ Varnish implements only one feature!
§ <esi:include src=”uri” />
∂ Examples? http://esi-examples.akamai.com
32
73. EDGE SIDE INCLUDES (3)
if (req.url ~ "^/url/to/esi/snippets") {
unset beresp.http.set-cookie;
}
## enable esi on header from backend
if (beresp.http.enable-esi == "1") {
set beresp.do_esi = true; //varnish 3.0
unset beresp.http.enable-esi;
}
∂ VCL config for ESI
33
82. CAVEATS
∂ Unsuitable for 32 bit
∂ Beware of cookie monster applications
∂ Check your API design
∂ Avoid large files
∂ Minimize cookie usage in ESI
∂ No SSL support
39