varnish and drupal- accelerating website performance and flexibility with varnish cache

35
Webinar Audio Options Listen to streaming audio via your computer’s audio – WebEx Audio Broadcast pop-up Unable to listen via your computer’s audio – Request phone access Technical support – US & Canada 866-229-3239 – International support 408- 435-7088 International phone access numbers: – http://support.webex.com/ support/phone-numbers.html

Upload: acquia

Post on 08-May-2015

4.824 views

Category:

Technology


3 download

DESCRIPTION

As enterprises continue to adopt Drupal for building and deploying high performance web applications, the need for high-performance caching becomes integral to their implementation strategy. Acquia and Varnish partner to deliver the ideal caching solution for optimizing web performance allowing developers to focus on creating great websites. Acquia will discuss how we've implemented Varnish in Acquia Hosting to improve performance for our customers, as well as the best practices that can help improve performance of any Drupal website. Join us for this complimentary webinar where we'll discuss: - Considerations for managing a high-performance site - How to manage caching behaviors in Drupal - Tools and tips for improving site performance

TRANSCRIPT

Page 1: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Webinar Audio OptionsListen to streaming audio via your computer’s audio– WebEx Audio Broadcast pop-up

Unable to listen via your computer’s audio– Request phone access

Technical support– US & Canada 866-229-3239– International support 408-435-

7088

International phone access numbers: – http://support.webex.com/

support/phone-numbers.html

Page 2: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Introduction

Matt Ackley– Marketing Team– @mbackley

Page 3: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Varnish + DrupalAccelerating Drupal Performance

and Flexibility with Varnish Cache

Varnish + DrupalAccelerating Drupal Performance

and Flexibility with Varnish Cache

Kurt Gray

Hosting Engineer

Acquia Inc.

@kurt

Kristian Lyngstøl

Software Engineer

Varnish Software

@kristian

Matt Ackley

Marketing

Acquia Inc.

@mbackley

Page 4: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Webinar Audio OptionsListen to streaming audio via your computer’s audio

– WebEx Audio Broadcast pop-up

Unable to listen via your computer’s audio

– Request phone access

Technical support– US & Canada 866-229-3239– International support 408-435-

7088

– International phone access numbers: http://support.webex.com/support/phone-numbers.html

Page 5: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Housekeeping

Today’s webinar is being recorded. Slides and recording will be posted in next 48 hours at:

–http://acquia.com/resources/recorded_webinars

Submit questions via Q&A Tab in WebEx, we’ll answer as many as we can

–Give it a try & tell us where you joining from today

Page 6: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Upcoming Events

Cities– New York City, November

9th

– Washington DC, November 18th

– Chicago, November 30th

– San Francisco, December 2nd

Target Audience– Senior IT & Marketing

professionals

Companies Speaking

– New York Stock Exchange

– tmg-emedia (Time Out)

– New York State Senate

– The 451 Group

– Gilbane Group

– VML

– Taunton Press

– Zagat Survey

– Examiner.comRegister at: http://revolution2010.acquia.com/

Page 7: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Recently Recorded Webinars

Client Advisor Webinar - Drupal Staging and Deployment Best Practices

Going from Zero to 60 in Drupal with Acquia

Watch Today at –

http://acquia.com/resources/recorded_webinars

Page 8: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Introduction

Kristian Lyngstol– Varnish Software– @kristian

Page 9: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

What is Varnish?

• Reverse proxy cache server• ... and more (load balancer, filter, director, ...)• Open Source (BSD), commercially supported • Typically in front of a LAMP stack:

Page 10: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Example Benchmarks: pages/second

• Typical HA Drupal stack: 200 Drupal pages/minute• ... with Varnish: 2500 Drupal pages/second• ... using smaller backend hardware!

Page 11: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Example Benchmarks: Page latency

• Varnish also improves response times:

Page 12: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Use cases for Varnish

• Typical: Reverse proxy cache in front LAMP stack• As a web request load balancer• ... or behind a load balancer• Behind a CDN• Next to a CDN• As a CDN• With other proxy caches• ...and more!

Page 13: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

What does Varnish do?• Caches backend responses, delivers from cache

Page 14: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

How does it work?• Varnish stores a cache entry for each Host + URL

Page 15: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

What can be cached in Varnish?• Drupal pages for anonymous users• Static content: images, js, css• Other types of static or generated content

What should NOT be cached in Varnish?• Responses to POST requests• Responses with a Set-Cookie: header • User-specific content (logged-in page requests)• Very large media files (> 100MB)• Has a Cache-Control: no-cache header

  All cache policies can be tuned using VCL

Page 16: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

How long will it be cached in Varnish?• Response header: Cache-Control: max-age=300• If no Cache-Control specified then Varnish uses

the Expires date, if specified • If no Cache-Control or Expires header then

uses Varnish's default TTL, 2 minutes (adjustable)

All cache policies can be tuned using VCL ...

Page 17: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

VCL: Varnish Configuration Language• Extend and modify Varnish cache policies• Add behaviors during each phase of delivery: recv, hash, fetch, hit, miss, deliver, ...

sub vcl_recv {

   # direct image requests to image servers   if (req.url ~ "(jpg|gif|png)") {      set req.backend = image_servers;   } }

Page 18: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

VCL: Varnish Configuration Language• Add/remove/change request or response headers

sub vcl_deliver {

   # Add a HIT/MISS header to the response   if (obj.hits > 0) {     set resp.http.X-Cache = "HIT";     set resp.http.X-Cache-Hits = obj.hits;    } else {     set resp.http.X-Cache = "MISS";   } }

Page 19: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Other VCL capabilities

• Add/remove/change HTTP headers• Redirects based on request parameters• Rewrite requests• Retry failed requests• Synthesize direct responses • Saint and Grace: Deliver cached content when

backend is unresponsive• ACLs: Network-address filtering• Request filtering• ESI: Separate cache entries and separate cache

policies for each part of a document• Inline C code (eg. redirects based on GeoIP) 

Page 20: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish realtime tools

• varnishstat: realtime status and performance metrics

Page 21: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish realtime tools

• varnishhist: live frequency plot of response times

Page 22: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish realtime tools

• Varnish CLI: live admin capabilities

Page 23: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish realtime tools

• varnishtop: live list of hottest files

Page 24: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish realtime tools

• varnishtop: analyze incoming HTTP headers

Page 25: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Introduction

Kurt Gray– Hosting Engineer– @kurt

Page 26: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Drupal: Cache variances

• Drupal emits Vary: Cookie,Accept-Encoding• Cookie: Avoids cache collisions between users• Accept-Encoding: maintain separate cache

entries for compressed content (gzip, deflate) vs. uncompressed content

Page 27: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Drupal: VCL snippets

sub vcl_recv {

   # Normalize the Accept-Encoding header    if (req.http.Accept-Encoding) {      if (req.http.Accept-Encoding ~ "gzip") {        set req.http.Accept-Encoding = "gzip";      } elsif (req.http.Accept-Encoding ~ "deflate") {        set req.http.Accept-Encoding = "deflate";      } else {        # unkown algorithm        remove req.http.Accept-Encoding;      }    } }

Page 28: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Drupal: VCL snippets

sub vcl_recv {

    # Don't check cache for logged-in users    if(req.http.cookie ~ "SESS") {      return(pass);    }

    # Cookie Bypass module: Don't check cache for anon    # user who POSTed content less than 10 minutes ago.    if(req.http.cookie ~ "NO_CACHE") {      return(pass);    } }

Page 29: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Drupal: VCL snippets

sub vcl_recv {

    # Don't check cache for GET /cron.php    if(req.url ~ "^/cron.php") {      return(pass);    } }

Page 30: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Drupal: VCL snippets

sub vcl_fetch {

    # Don't cache if response has explicit no-cache headers    if (beresp.http.Pragma ~ "no-cache" ||       beresp.http.Cache-Control ~ "no-cache" ||       beresp.http.Cache-Control ~ "private") {         return(pass);    } }

Page 31: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Pressflow Drupal, D7

• Pressflow = Drupal w/ many performance tweaks• Allows Varnish to cache and deliver Drupal page

requests for anonymous visitors• ...because Pressflow doesn't emit "lazy sessions" • No SESS cookies for anonymous visitors• Drupal 7 has same key features

Page 32: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Controlling cache expiration times

• Drupal Admin > Performance pageo Agressive or External cachingo Minimum Page Lifetime = max-age

• Active purging: use Drupal Varnish module• Static content: See the mod_expires directives in

Drupal's .htaccess file• If no Cache-Control or Expires headers: Uses

Varnish's default TTL (2 minutes)

Page 33: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

© 2010 Acquia, Inc.

Varnish and Acquia Hosting

• All Acquia-hosted sites benefit from Varnish• Pressflow sites on Acquia-hosting get most benefit• Fully managed HA environment: No setup, no fuss• Reduces backend server size requirments• Excellent load test results

Page 34: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

Do you love working with Drupal?

If so, Acquia is hiring in North America & Europe:–Engineering & design–Client advisors and consulting–Inside sales

Check out openings athttp://acquia.com/careers

Page 35: Varnish and Drupal- Accelerating Website Performance and Flexibility with Varnish Cache

QuestionsFor more information, visit:– http://acquia.com

– http://twitter.com/acquia

– http://twitter.com/drupalgardens

– http://twitter.com/drupalcommons

– http://acquia.com/facebook

Contact us:– [email protected]

– 888.9.ACQUIA

Try Drupal 7 today, for free – Sign up at http://drupalgardens.com

• Sign up for the Drupal Business Summit– http://revolution2010.acquia.com/

Recording of today’s event and slideswill be posted at:

http://acquia.com/resources/recorded_webinars