Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Steven Merrill

@stevenmerrill

It's a reverse proxy cache.

It sits in front of the web servers.

Run it on your webservers or on dedicated boxes.

It can store cached items in memory or on disk.

It's faster because it's C!

(Yes, even the configuration.)

You can program it with VCL.

Nearly all anonymous / static traffic can be offloaded from Apache*.

* With some work, fragments can also be cached with ESI**.

**Edge-Side Includes

Varnish efficiently handles many threads.

Varnish is a capable HTTP load balancer.

You can prevent cache

stampedes with grace mode.

You can serve stale content if your backends are all unavailable.

You can leave error-prone pages alone for a period of time with saint mode.

It has awesome command-line tools.

You can load new configurations on the fly without dumping the cache.

Work is on the way to support conditional requests and streaming.

Vanilla Drupal 6 isn't very amenable to Varnishing.

Pressflow to the rescue!

Pressflow 6 has the 'external' cache mode.

It disables Drupal's page cache and sends caching-friendly headers.

It also sends the Vary: Cookie header on all pages it serves.

Drupal 7 works out of the box!

It sends all the right headers.

It's also much smarter about Vary: headers.

Contrib modules to watch:

Expire

Context HTTP Headers

Purge

Varnish

Pressflow 6

Drupal 7

Varnish (6/7)

Intro to VCL

The Pressflow VCL

The Varnish CLI

Sandbox Projects

I Can Haz?

Pantheon

Acquia Hosting

Cadre Hosting

Feedback!

http://tha.cm/varnish-talk

Questions?

Coat Your Website with Varnish

BADCamp 2011

Treehouse Agency

WHY

(https://wiki.fourkitchens.com/display/PF/Configure+Varnish+for+Pressflow)

Backends

  • Specify hosts and ports.
  • Define connection timeouts.
  • Define a health check URL, including sending custom headers if needed.

?

vcl_recv()

  • React to an incoming request.
  • Alter headers before they head to the backend.

vcl_pipe()

varnishd

varnishlog

varnishtop

varnishstat

varnishadm

  • React to something being piped directly to the backend.
  • The Varnish daemon itself.
  • You can invoke it by hand to check the syntax of a VCL file or the Varnish version.
  • View all log entries but not in a summarized fashion.
  • Accepts the same switches as varnishtop.
  • Get high-level running totals of your Varnish install.
  • See cache hitrate over time.
  • View a weighted total of varnish log entries.
  • Filter to look for patterns.
  • See `man varnishtop` for info.
  • Connect to Varnish's control terminal on port 6082.
  • Load and change configurations without a restart.
  • Check out overall stats.
  • Issue bans/purges.

vcl_pass()

  • React to something being passed through to be retrieved from the backend but not cached.

varnishadm -T localhost:6082

varnishlog -i Backend_health

varnishtop -i TxURL -I esi

vcl.load newconfig /path/to/the.vcl

vcl.use newconfig

vcl.discard boot

varnishd -C -f <path to your .vcl file>

varnishd -V

varnishtop -i RxURL

varnishtop -i TxURL

varnishtop -i RxURL -I User-Agent

varnishtop -i TxHeader -I Content-Type

ban.url ~ "^/node/1"

ban req.url ~ "^/node/1"&&

req.http.Host == "treehouseagency.com"

ban.list

vcl_hash()

  • Set Varnish's cache hash.
  • This defaults to url + host/ip.
  • Varnish also respects Vary headers.

vcl_hit()

  • React to a cache hit!
  • :-D

vcl_miss()

  • React to a cache miss.
  • :'-(

vcl_fetch()

  • React after something has been fetched from a backend.
  • Change response headers before something enters cache.
  • You may perform ESI.

Panels ESI Cache

Varnish Cache Tagging

http://drupal.org/sandbox/smerrill/1310946

http://drupal.org/sandbox/smerrill/1308884

vcl_deliver()

  • React as something will be delivered to a client.
  • Change response headers before delivery.
  • You probably want to perform ESI in this step.

vcl_error()

  • React to an error condition.
  • Use the `synthetic` keyword to make an HTML error page.
  • You must do redirects with vcl_error().
Learn more about creating dynamic, engaging presentations with Prezi