Drupal Cache Luis F. Ribeiro Ci&T Inc. 2013 Introduction Caio - - PowerPoint PPT Presentation

drupal cache
SMART_READER_LITE
LIVE PREVIEW

Drupal Cache Luis F. Ribeiro Ci&T Inc. 2013 Introduction Caio - - PowerPoint PPT Presentation

The importance of Drupal Cache Luis F. Ribeiro Ci&T Inc. 2013 Introduction Caio Ciao Luppi Software Architect at Ci&T Inc. More than 4 years of experience with Drupal Development Experience with Application Development


slide-1
SLIDE 1

The importance of Drupal Cache

Luis F. Ribeiro Ci&T Inc. 2013

slide-2
SLIDE 2

www.ciandt.com

Introduction

2

  • Caio Ciao Luppi
  • Software Architect at Ci&T Inc.
  • More than 4 years of experience with Drupal

Development

  • Experience with Application Development and

Support using Drupal 6 and Drupal 7 Platforms

slide-3
SLIDE 3

www.ciandt.com

Ci&T Inc.

3

slide-4
SLIDE 4

www.ciandt.com

Why use Cache ?

4

  • Faster response time will increase the user

experience

  • Optimizing / rewriting code is often expensive
  • r not an option
  • Lower data center costs
  • Reduce the CMS Workflow overhead
slide-5
SLIDE 5

www.ciandt.com

Why use Cache ?

5

slide-6
SLIDE 6

www.ciandt.com

Cache Options

6

Drupal Modules/Distros

  • Page Cache
  • Boost Cache
  • Authenthicated Cache
  • PressFlow

Other Cache Options

  • Varnish
  • APC
  • CDN (Akamai, Amazon CloudFront, Level 3)
  • Memcache
slide-7
SLIDE 7

www.ciandt.com

Page Cache

7

  • Out of the box Drupal page caching mechanism
  • Saves rendered pages directly into the database
  • By default only caches anonymous requests
  • Hook_boot and hook_exit are always called – unless

you’re using the aggressive cache option

slide-8
SLIDE 8

www.ciandt.com

Memcache

8

  • High-performance, distributed memory object

caching system

  • Reduces database hits
  • Cached data is stored in web server memory
  • It works awesomely if the database is in a different

server

slide-9
SLIDE 9

www.ciandt.com

Memcache

9

slide-10
SLIDE 10

www.ciandt.com

Memcache – Install

10

High-level steps to install memcache

  • 1. Install memcached daemon
  • 2. Install and configure PHP memcache extension
  • 3. Install and enable memcache Drupal module
  • 4. Configure Drupal to use memcache
slide-11
SLIDE 11

www.ciandt.com

Boost

11

  • Module solution that provides static page caching
  • Signifcant performance improvement for

unauthenticated traffic

  • Supports shared, VPS and dedicated hosting
  • Requires cron & clean urls to work properly
  • Have to edit .htaccess and robots.txt files
slide-12
SLIDE 12

www.ciandt.com

Boost - Flow

12

slide-13
SLIDE 13

www.ciandt.com

Authenticated User Page Caching (Authcache)

13

  • Most popular solution for authenticated caching
  • Caches final rendered HTML per role and makes AJAX

calls to get user specific content

  • Ability to use different types of caching (database,

memcache, etc...)

slide-14
SLIDE 14

www.ciandt.com

Authcache Flow

14

slide-15
SLIDE 15

www.ciandt.com

Authcache Disadvantages

15

  • Requires changes on how user-customized content is

displayed

  • Increases development time and testing
  • Not suited for heavy user-centric content
  • Hooks for contributed modules may need to be added

for compatibility

slide-16
SLIDE 16

www.ciandt.com

PressFlow

16

  • Drupal distribution with integrated performance,

scalability and availability enhancements

  • Drupal 6 and Drupal 7 versions
  • Provides integration with Varnish and allows for

MySQL replication

  • The key enhancements from Pressflow 6 were added

to Drupal 7.

slide-17
SLIDE 17

www.ciandt.com

Varnish

17

slide-18
SLIDE 18

www.ciandt.com

Varnish

18

  • HTTP reverse proxy solution
  • Default caching solution used at Acquia servers
  • Focused exclusively on HTTP, unlike other proxy

servers that often support FTP, SMTP, etc

  • Supports load balancing
slide-19
SLIDE 19

www.ciandt.com

CDN – Content Delivery Network

19

  • Geographically distributed servers
  • Delivers the fastest possible download for all users

based on location

  • Focused on files (resources) referenced by the HTML,

such as CSS, JavaScript, fonts and images

  • Free CDNs: CloudFlare, Coral Content Distribution

Network

  • Commercial CDNs: Akamai Technologies, Amazon

CloudFront, Level 3 Communications, etc

slide-20
SLIDE 20

www.ciandt.com

What if we use them all…

20

slide-21
SLIDE 21

www.ciandt.com

Cache

21

~20ms ~100ms ~200ms ~600ms ~2000ms

slide-22
SLIDE 22

www.ciandt.com

Front-end Improvements

22

  • Sprites
  • Compressing images
  • Minify and aggregate JS and CSS files
  • Using tool that will help you to analyze and improve

front-end performance (YSlow, Web Page Analyzer, Firebug, etc)

slide-23
SLIDE 23

www.ciandt.com

Benchmarking / Load Test

23

  • Load testing tools
  • Loadrunner
  • Jmeter
  • Etc…
  • Analyze results
  • Response Time
  • Throughput
slide-24
SLIDE 24

www.ciandt.com

Load Test – CDN & Page Cache Example

BEFORE AFTER 50s 13s

0 to 500 Vusers 0 to 500 Vusers

slide-25
SLIDE 25

www.ciandt.com

Load Test – CDN & Page Cache Example

25

BEFORE AFTER 9,500,000 4,500,000

slide-26
SLIDE 26

www.ciandt.com

Problems / Risks

26

  • Authenticated users
  • Caching what’s not supposed to be cached
  • Dynamic/random content
  • Personalized content
  • Etc…
  • Actual content and cache can be out of sync
slide-27
SLIDE 27

www.ciandt.com

What to do when nothing works…

slide-28
SLIDE 28

www.ciandt.com

Troubleshooting

28

  • Clear cache (Drupal, Varnish, CDN, etc…) and try

again

  • Force a new request using random query strings

(?asdasdasd)

  • Disable cache for authenticated users
  • Use helper tools/modules/modes (debug mode,

memcache interface, etc…)

slide-29
SLIDE 29

www.ciandt.com

Questions?

29

Questions?

slide-30
SLIDE 30