SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Cache All The Things




               Mike Bell - @mikebell_
About Me
Mike Bell
Lead Drupal Developer @ Ixis

@mikebell_
http://drupal.org/user/189605
Exactly what things?
well errr...

everything!
No really...
Frontend:
- HTML
- CSS
- Images
- Javascript
Backend:
- PHP
- MySQL
So pretty much everything then!
Where to start?
Ask yourself:
             Why is my site slow?

a) Bad code
b) Bad server
c) It's not!
Bad Code?
Stop.

Caching will help... but it won't solve your
bigger issues.

There are tools to help - xhprof
Bad Server?
So how's £5.99 a month working out for you?

Caching will help... but again you still have
bigger issues.

Scale horizontally/vertically for a quick fix then
work on additional caching.
It's not!
I like you!

Caching is always a good thing, except when
you have to debug it...
Caching in Drupal
- Code Level (cache_get/cache_set)
- APC (not covered here)
- Resource caching (this get's tricky!)
- DB Layer
- CDNs (related to resource caching)
Code Level
Drupal has it's own caching api.

Module Developers use it!

cache_set - store data in Drupals cache table
cache_get - get data from Drupals cache table

You can even define your own cache tables!
Resource Caching
Many different types of resources

Each can be cached by different tools

Example:
- Drupals CSS/JS Cache
- Drupals Page Cache
- Boost
- Varnish
Resource Caching
Drupal default: CSS/JS and Page




(taken from mikebell.io - ooppss!)
Resource Caching - Boost
Boost - http://drupal.org/project/boost

Static caching for all Drupal Assets

Anonymous users only

Ideal for shared hosting environments

Potentially the easiest to setup
Resource Caching - Varnish
Application Accelerator

Linux Only

Caches resources based on initial view

Anonymous only - very picky with sessions and cookies

Insanely Powerful
Resource Caching - Varnish
Advanced setup - requires additional module
and VCL for Drupal
- http://drupal.org/project/varnish

Granular ttls (time to live)

Specific resource (image/css) and page
element! All available through VCL config.
Resource Caching - Varnish
Cache Stores
- RAM
- Disk

Ram - super fast - requires a lot of ram
Disk - fast - disk space is rarely an issue
Data Caching - memcached

Data and Database caching layer

Caches cache... (and things!)
Data Caching - memcached
Example:
Core cache - core cache tables (cache_*)

Moved into memcached and shared between multiple
instances across multiple servers

Simple api makes getting and setting easy

Drupal requires - http://drupal.org/project/memcache and
pecl extension
3rd Party Caching - Akamai
One of the biggest caching providers

A high chance you've experienced Akamai
today without realising it.

Static cache of resources
Content Distribution Network
100+ Edge servers all over the world
3rd Party Caching - Akamai
Coverage for DDOS attacks
- Active monitoring and defense

Advanced redirection rules through control panel

It's not cheap!

It's also pretty magical.
3rd Party Caching - Cloudflare
Similar to Akamai

Smaller scale

Emphasis on security and DDOS protection
Content Distribution Network
CDNs for short

Offload resource handling to external provider
- Images
- Video
- Audio
- Large files

Syndicate content around the world
Content Distribution Network
Why use a CDN?
- Content is delivered quicker
-- Latency cut down

Pricing is granular - pay as you go type deal

Amazon + Rackspace Cloud Files
How does it all fit together?
What happens when it all goes wrong?
Caching to the rescue!
Each layer provides protection

3rd Party - shield 99% of anon traffic
Varnish - the rest

Anonymous users should never know your site
has issues.
Debugging Tips
Configure different urls for different platforms
- Easier to identify what cache layer has an issue

Don't be afraid to flush caches
- Your backend should be able to cope with it

Analyse headers! Drupal and Varnish provide a lot of info

Akamai information can be gleaned from additional http
headers.
Debugging Tips
Monitor each layer
- Icinga
- Pingdom
Any Questions?




                 Slide designs by Ritch Partridge (@ritchpartridge)

Contenu connexe

Tendances

Optimizing Drupal Performance (English)
Optimizing Drupal Performance (English)Optimizing Drupal Performance (English)
Optimizing Drupal Performance (English)Timur Kamanin
 
Memcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainMemcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainDrupal Camp Delhi
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and ScalingGerald Villorente
 
Drupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersMarcus Deglos
 
Drupal caching
Drupal cachingDrupal caching
Drupal cachingExove
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
High Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nlHigh Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nlJoomla!Days Netherlands
 
Hong Kong Drupal User Group - Sep 13th
Hong Kong Drupal User Group - Sep 13thHong Kong Drupal User Group - Sep 13th
Hong Kong Drupal User Group - Sep 13thWong Hoi Sing Edison
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningTimothy Wood
 
How to reduce database load using Memcache
How to reduce database load using MemcacheHow to reduce database load using Memcache
How to reduce database load using Memcachevaluebound
 
Caching Data For Performance
Caching Data For PerformanceCaching Data For Performance
Caching Data For PerformanceDave Ross
 
Django book15 caching
Django book15 cachingDjango book15 caching
Django book15 cachingShih-yi Wei
 
Skalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.comSkalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.comSpodek 2.0
 
Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarSwatantra Kumar
 
Intro to CouchDB
Intro to CouchDBIntro to CouchDB
Intro to CouchDBbenaldred
 
Get Started With Drupal
Get Started With DrupalGet Started With Drupal
Get Started With DrupalKartik Singhal
 
Optimising PyroCMS for speed and performance boosts
Optimising PyroCMS for speed and performance boostsOptimising PyroCMS for speed and performance boosts
Optimising PyroCMS for speed and performance boostssaintsatplay
 

Tendances (20)

Optimizing Drupal Performance (English)
Optimizing Drupal Performance (English)Optimizing Drupal Performance (English)
Optimizing Drupal Performance (English)
 
Memcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainMemcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav Jain
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and Scaling
 
Drupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappers
 
Drupal caching
Drupal cachingDrupal caching
Drupal caching
 
Caching
CachingCaching
Caching
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
High Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nlHigh Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nl
 
Hong Kong Drupal User Group - Sep 13th
Hong Kong Drupal User Group - Sep 13thHong Kong Drupal User Group - Sep 13th
Hong Kong Drupal User Group - Sep 13th
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & Tuning
 
How to reduce database load using Memcache
How to reduce database load using MemcacheHow to reduce database load using Memcache
How to reduce database load using Memcache
 
Caching Data For Performance
Caching Data For PerformanceCaching Data For Performance
Caching Data For Performance
 
Varnish bof
Varnish bofVarnish bof
Varnish bof
 
Django book15 caching
Django book15 cachingDjango book15 caching
Django book15 caching
 
Skalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.comSkalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.com
 
Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra Kumar
 
Intro to CouchDB
Intro to CouchDBIntro to CouchDB
Intro to CouchDB
 
Get Started With Drupal
Get Started With DrupalGet Started With Drupal
Get Started With Drupal
 
Hands on workshop on word press
Hands on workshop on word pressHands on workshop on word press
Hands on workshop on word press
 
Optimising PyroCMS for speed and performance boosts
Optimising PyroCMS for speed and performance boostsOptimising PyroCMS for speed and performance boosts
Optimising PyroCMS for speed and performance boosts
 

En vedette

NWDUG Back to Basics - Part 1
NWDUG Back to Basics - Part 1NWDUG Back to Basics - Part 1
NWDUG Back to Basics - Part 1digital006
 
Electric motors and generators
Electric motors and generatorsElectric motors and generators
Electric motors and generatorsRakesh Pathipati
 
3phase induction motor
3phase induction motor3phase induction motor
3phase induction motorNaveen Sihag
 
Induction Synchronous Motor
Induction Synchronous MotorInduction Synchronous Motor
Induction Synchronous MotorShahzad Khalil
 
Types of Lighting and Luminaire
Types of Lighting and LuminaireTypes of Lighting and Luminaire
Types of Lighting and Luminairekaycelles
 
POWER ELECTRONIC DEVICES
POWER ELECTRONIC DEVICESPOWER ELECTRONIC DEVICES
POWER ELECTRONIC DEVICESshazaliza
 

En vedette (9)

NWDUG Back to Basics - Part 1
NWDUG Back to Basics - Part 1NWDUG Back to Basics - Part 1
NWDUG Back to Basics - Part 1
 
Induction motor
Induction motorInduction motor
Induction motor
 
Electric motors and generators
Electric motors and generatorsElectric motors and generators
Electric motors and generators
 
3phase induction motor
3phase induction motor3phase induction motor
3phase induction motor
 
Induction Synchronous Motor
Induction Synchronous MotorInduction Synchronous Motor
Induction Synchronous Motor
 
Types of Lighting and Luminaire
Types of Lighting and LuminaireTypes of Lighting and Luminaire
Types of Lighting and Luminaire
 
Power Quality
Power QualityPower Quality
Power Quality
 
POWER ELECTRONIC DEVICES
POWER ELECTRONIC DEVICESPOWER ELECTRONIC DEVICES
POWER ELECTRONIC DEVICES
 
Power quality ppt
Power quality pptPower quality ppt
Power quality ppt
 

Similaire à Cache all the things #DCLondon

Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceAshok Modi
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and ScalabilityMediacurrent
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archroyans
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archguest18a0f1
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archmclee
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!WordCamp Cape Town
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesExove
 
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...WordCamp Harare
 
WordCamp Harare 2016 - Site Speed = Success
WordCamp Harare 2016 - Site Speed = SuccessWordCamp Harare 2016 - Site Speed = Success
WordCamp Harare 2016 - Site Speed = SuccessAnthony Somerset
 
Caching and tuning fun for high scalability @ PHPTour
Caching and tuning fun for high scalability @ PHPTourCaching and tuning fun for high scalability @ PHPTour
Caching and tuning fun for high scalability @ PHPTourWim Godden
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)WordCamp Cape Town
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan Ollendyke
 

Similaire à Cache all the things #DCLondon (20)

Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performance
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
 
WordCamp Harare 2016 - Site Speed = Success
WordCamp Harare 2016 - Site Speed = SuccessWordCamp Harare 2016 - Site Speed = Success
WordCamp Harare 2016 - Site Speed = Success
 
Caching and tuning fun for high scalability @ PHPTour
Caching and tuning fun for high scalability @ PHPTourCaching and tuning fun for high scalability @ PHPTour
Caching and tuning fun for high scalability @ PHPTour
 
Scaling 101 test
Scaling 101 testScaling 101 test
Scaling 101 test
 
Scaling 101
Scaling 101Scaling 101
Scaling 101
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 

Cache all the things #DCLondon

  • 1. Cache All The Things Mike Bell - @mikebell_
  • 2. About Me Mike Bell Lead Drupal Developer @ Ixis @mikebell_ http://drupal.org/user/189605
  • 3. Exactly what things? well errr... everything!
  • 4. No really... Frontend: - HTML - CSS - Images - Javascript Backend: - PHP - MySQL So pretty much everything then!
  • 5. Where to start? Ask yourself: Why is my site slow? a) Bad code b) Bad server c) It's not!
  • 6. Bad Code? Stop. Caching will help... but it won't solve your bigger issues. There are tools to help - xhprof
  • 7. Bad Server? So how's £5.99 a month working out for you? Caching will help... but again you still have bigger issues. Scale horizontally/vertically for a quick fix then work on additional caching.
  • 8. It's not! I like you! Caching is always a good thing, except when you have to debug it...
  • 9. Caching in Drupal - Code Level (cache_get/cache_set) - APC (not covered here) - Resource caching (this get's tricky!) - DB Layer - CDNs (related to resource caching)
  • 10. Code Level Drupal has it's own caching api. Module Developers use it! cache_set - store data in Drupals cache table cache_get - get data from Drupals cache table You can even define your own cache tables!
  • 11. Resource Caching Many different types of resources Each can be cached by different tools Example: - Drupals CSS/JS Cache - Drupals Page Cache - Boost - Varnish
  • 12. Resource Caching Drupal default: CSS/JS and Page (taken from mikebell.io - ooppss!)
  • 13. Resource Caching - Boost Boost - http://drupal.org/project/boost Static caching for all Drupal Assets Anonymous users only Ideal for shared hosting environments Potentially the easiest to setup
  • 14. Resource Caching - Varnish Application Accelerator Linux Only Caches resources based on initial view Anonymous only - very picky with sessions and cookies Insanely Powerful
  • 15. Resource Caching - Varnish Advanced setup - requires additional module and VCL for Drupal - http://drupal.org/project/varnish Granular ttls (time to live) Specific resource (image/css) and page element! All available through VCL config.
  • 16. Resource Caching - Varnish Cache Stores - RAM - Disk Ram - super fast - requires a lot of ram Disk - fast - disk space is rarely an issue
  • 17. Data Caching - memcached Data and Database caching layer Caches cache... (and things!)
  • 18. Data Caching - memcached Example: Core cache - core cache tables (cache_*) Moved into memcached and shared between multiple instances across multiple servers Simple api makes getting and setting easy Drupal requires - http://drupal.org/project/memcache and pecl extension
  • 19. 3rd Party Caching - Akamai One of the biggest caching providers A high chance you've experienced Akamai today without realising it. Static cache of resources Content Distribution Network 100+ Edge servers all over the world
  • 20. 3rd Party Caching - Akamai Coverage for DDOS attacks - Active monitoring and defense Advanced redirection rules through control panel It's not cheap! It's also pretty magical.
  • 21. 3rd Party Caching - Cloudflare Similar to Akamai Smaller scale Emphasis on security and DDOS protection
  • 22. Content Distribution Network CDNs for short Offload resource handling to external provider - Images - Video - Audio - Large files Syndicate content around the world
  • 23. Content Distribution Network Why use a CDN? - Content is delivered quicker -- Latency cut down Pricing is granular - pay as you go type deal Amazon + Rackspace Cloud Files
  • 24. How does it all fit together?
  • 25. What happens when it all goes wrong?
  • 26. Caching to the rescue! Each layer provides protection 3rd Party - shield 99% of anon traffic Varnish - the rest Anonymous users should never know your site has issues.
  • 27. Debugging Tips Configure different urls for different platforms - Easier to identify what cache layer has an issue Don't be afraid to flush caches - Your backend should be able to cope with it Analyse headers! Drupal and Varnish provide a lot of info Akamai information can be gleaned from additional http headers.
  • 28. Debugging Tips Monitor each layer - Icinga - Pingdom
  • 29. Any Questions? Slide designs by Ritch Partridge (@ritchpartridge)