Lightning talk given at Refresh Cambridge event on 6th July 2011. Very quick introduction to where an HTTP Caching solution fits in, and an example of the kind of effect it could have on performance.
7. “Varnish Cache is an open source, state of
the art web application accelerator. You
install it on your web server and it makes
your website fly.
Official blurb
What is Varnish?
gareth rushgrove | morethanseven.net http://www.flickr.com/photos/exalthim/3597210568
8. - Cache
- Reverse Proxy
- HTTP Accelerator
Seriously, what is Varnish?
gareth rushgrove | morethanseven.net
9. A Story of HTTP Caching
gareth rushgrove | morethanseven.net http://www.flickr.com/photos/solsken/62924477
10. Database Web Server Web Traffic
A Typical App
gareth rushgrove | morethanseven.net
11. Database Web Server
More Traffic == Slower responses
gareth rushgrove | morethanseven.net
12. Database Web Server
Eventually...
gareth rushgrove | morethanseven.net
13. Database Web Server Varnish
Add Varnish
gareth rushgrove | morethanseven.net
14. Database Web Server Varnish
Deal with more traffic
gareth rushgrove | morethanseven.net
17. memcached Gunicorn Varnish Nginx
Database
memcached Gunicorn Varnish Nginx
Overengineering for Fun
18. backend default {
.host = "127.0.0.1";
.port = "8000";
}
sub vcl_recv {
if (req.request == "GET" && req.http.cookie) {
return(lookup);
}
}
sub vcl_fetch {
if (beresp.ttl < 180s) {
set beresp.ttl = 180s;
}
esi;
if (beresp.http.Set-Cookie) {
return(deliver);
}
}
Varnish Configuration
gareth rushgrove | morethanseven.net
19. ⚡ ab -c 10 -n 400 http://www.vagrantbox.es/
Requests per second: 59.63 [#/sec] (mean)
Percentage of the requests served within a certain time (ms)
50% 164
66% 174
75% 183
80% 188
90% 207
95% 231
98% 246
99% 279
100% 408 (longest request)
Without Varnish
gareth rushgrove | morethanseven.net
20. ⚡ ab -c 10 -n 400 http://www.vagrantbox.es/
Requests per second: 103.61 [#/sec] (mean)
Percentage of the requests served within a certain time (ms)
50% 92
66% 101
75% 107
80% 111
90% 120
95% 129
98% 141
99% 149
100% 157 (longest request)
With Varnish
gareth rushgrove | morethanseven.net