Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Varnish for Beginners

Varnish for Beginners

An introduction to Varnish the caching http accelerator. Showing some stats and a live demo of Varnish this presentation aims to bring unfamiliar users into the fold and to start using Varnish.

typhonius

June 13, 2013
Tweet

More Decks by typhonius

Other Decks in Technology

Transcript

  1. Varnish for Beginners Shielding Drupal from the internet http://adammalone.net |

    http://drupal.org/user/1295980 | @adammalone By Adam Malone
  2. Varnish Installation (yum|apt-get|brew) install varnish CentOS installation requires varnish repo

    http://adammalone.net | http://drupal.org/user/1295980 | @adammalone
  3. Varnish Configuration http://adammalone.net | http://drupal.org/user/1295980 | @adammalone DAEMON_OPTS="-a :80 \

    -u varnish -g varnish \ -T localhost:6082 \ -f /etc/varnish/adam.vcl \ -S /etc/varnish/secret \ -s malloc,256M" backend default { .host = "127.0.0.1"; .port = "8234"; } sub vcl... /etc/varnish/default.vcl /etc/sysconfig/varnish
  4. VCL sub vcl_recv vcl_pipe vcl_fetch vcl_deliver vcl_error http://adammalone.net | http://drupal.org/user/1295980

    | @adammalone return() pipe fetch restart deliver pass lookup error VCL docs Four Kitchens VCL request objs req besresp
  5. Checking Varnish works • Inspecting Headers • Watch the network

    tab • Check varnishlog (more later) • isvarnishworking.com http://adammalone.net | http://drupal.org/user/1295980 | @adammalone
  6. Breaking Varnish • Setting $_SESSION ◦ Authenticated users do not

    benefit ◦ Check {sessions} table • Cookies • Unique query paths • .htaccess http://adammalone.net | http://drupal.org/user/1295980 | @adammalone
  7. Comparison to other caches • Drupal cache tables • Boost

    • MongoDB • Memcache http://adammalone.net | http://drupal.org/user/1295980 | @adammalone
  8. Varnish Tools • varnishstat • varnishlog • varnishncsa • varnishhist

    http://adammalone.net | http://drupal.org/user/1295980 | @adammalone
  9. Extending Varnish • ESI • Varnish mods (vmods) • Don't

    be too greedy when caching • Don't deliver too promiscuously http://adammalone.net | http://drupal.org/user/1295980 | @adammalone Gotchas