Cache All The Things               Mike Bell - @mikebell_
About MeMike BellLead Drupal Developer @ Ixis@mikebell_http://drupal.org/user/189605
Exactly what things?well errr...everything!
No really...Frontend:- HTML- CSS- Images- JavascriptBackend:- PHP- MySQLSo pretty much everything then!
Where to start?Ask yourself:             Why is my site slow?a) Bad codeb) Bad serverc) Its not!
Bad Code?Stop.Caching will help... but it wont solve yourbigger issues.There are tools to help - xhprof
Bad Server?So hows £5.99 a month working out for you?Caching will help... but again you still havebigger issues.Scale hori...
Its not!I like you!Caching is always a good thing, except whenyou have to debug it...
Caching in Drupal- Code Level (cache_get/cache_set)- APC (not covered here)- Resource caching (this gets tricky!)- DB Laye...
Code LevelDrupal has its own caching api.Module Developers use it!cache_set - store data in Drupals cache tablecache_get -...
Resource CachingMany different types of resourcesEach can be cached by different toolsExample:- Drupals CSS/JS Cache- Drup...
Resource CachingDrupal default: CSS/JS and Page(taken from mikebell.io - ooppss!)
Resource Caching - BoostBoost - http://drupal.org/project/boostStatic caching for all Drupal AssetsAnonymous users onlyIde...
Resource Caching - VarnishApplication AcceleratorLinux OnlyCaches resources based on initial viewAnonymous only - very pic...
Resource Caching - VarnishAdvanced setup - requires additional moduleand VCL for Drupal- http://drupal.org/project/varnish...
Resource Caching - VarnishCache Stores- RAM- DiskRam - super fast - requires a lot of ramDisk - fast - disk space is rarel...
Data Caching - memcachedData and Database caching layerCaches cache... (and things!)
Data Caching - memcachedExample:Core cache - core cache tables (cache_*)Moved into memcached and shared between multiplein...
3rd Party Caching - AkamaiOne of the biggest caching providersA high chance youve experienced Akamaitoday without realisin...
3rd Party Caching - AkamaiCoverage for DDOS attacks- Active monitoring and defenseAdvanced redirection rules through contr...
3rd Party Caching - CloudflareSimilar to AkamaiSmaller scaleEmphasis on security and DDOS protection
Content Distribution NetworkCDNs for shortOffload resource handling to external provider- Images- Video- Audio- Large file...
Content Distribution NetworkWhy use a CDN?- Content is delivered quicker-- Latency cut downPricing is granular - pay as yo...
How does it all fit together?
What happens when it all goes wrong?
Caching to the rescue!Each layer provides protection3rd Party - shield 99% of anon trafficVarnish - the restAnonymous user...
Debugging TipsConfigure different urls for different platforms- Easier to identify what cache layer has an issueDont be af...
Debugging TipsMonitor each layer- Icinga- Pingdom
Any Questions?                 Slide designs by Ritch Partridge (@ritchpartridge)
Upcoming SlideShare
Loading in...5
×

Cache all the things #DCLondon

331

Published on

Cut down presentation for DrupalCamp London 2013

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
331
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cache all the things #DCLondon

  1. 1. Cache All The Things Mike Bell - @mikebell_
  2. 2. About MeMike BellLead Drupal Developer @ Ixis@mikebell_http://drupal.org/user/189605
  3. 3. Exactly what things?well errr...everything!
  4. 4. No really...Frontend:- HTML- CSS- Images- JavascriptBackend:- PHP- MySQLSo pretty much everything then!
  5. 5. Where to start?Ask yourself: Why is my site slow?a) Bad codeb) Bad serverc) Its not!
  6. 6. Bad Code?Stop.Caching will help... but it wont solve yourbigger issues.There are tools to help - xhprof
  7. 7. Bad Server?So hows £5.99 a month working out for you?Caching will help... but again you still havebigger issues.Scale horizontally/vertically for a quick fix thenwork on additional caching.
  8. 8. Its not!I like you!Caching is always a good thing, except whenyou have to debug it...
  9. 9. Caching in Drupal- Code Level (cache_get/cache_set)- APC (not covered here)- Resource caching (this gets tricky!)- DB Layer- CDNs (related to resource caching)
  10. 10. Code LevelDrupal has its own caching api.Module Developers use it!cache_set - store data in Drupals cache tablecache_get - get data from Drupals cache tableYou can even define your own cache tables!
  11. 11. Resource CachingMany different types of resourcesEach can be cached by different toolsExample:- Drupals CSS/JS Cache- Drupals Page Cache- Boost- Varnish
  12. 12. Resource CachingDrupal default: CSS/JS and Page(taken from mikebell.io - ooppss!)
  13. 13. Resource Caching - BoostBoost - http://drupal.org/project/boostStatic caching for all Drupal AssetsAnonymous users onlyIdeal for shared hosting environmentsPotentially the easiest to setup
  14. 14. Resource Caching - VarnishApplication AcceleratorLinux OnlyCaches resources based on initial viewAnonymous only - very picky with sessions and cookiesInsanely Powerful
  15. 15. Resource Caching - VarnishAdvanced setup - requires additional moduleand VCL for Drupal- http://drupal.org/project/varnishGranular ttls (time to live)Specific resource (image/css) and pageelement! All available through VCL config.
  16. 16. Resource Caching - VarnishCache Stores- RAM- DiskRam - super fast - requires a lot of ramDisk - fast - disk space is rarely an issue
  17. 17. Data Caching - memcachedData and Database caching layerCaches cache... (and things!)
  18. 18. Data Caching - memcachedExample:Core cache - core cache tables (cache_*)Moved into memcached and shared between multipleinstances across multiple serversSimple api makes getting and setting easyDrupal requires - http://drupal.org/project/memcache andpecl extension
  19. 19. 3rd Party Caching - AkamaiOne of the biggest caching providersA high chance youve experienced Akamaitoday without realising it.Static cache of resourcesContent Distribution Network100+ Edge servers all over the world
  20. 20. 3rd Party Caching - AkamaiCoverage for DDOS attacks- Active monitoring and defenseAdvanced redirection rules through control panelIts not cheap!Its also pretty magical.
  21. 21. 3rd Party Caching - CloudflareSimilar to AkamaiSmaller scaleEmphasis on security and DDOS protection
  22. 22. Content Distribution NetworkCDNs for shortOffload resource handling to external provider- Images- Video- Audio- Large filesSyndicate content around the world
  23. 23. Content Distribution NetworkWhy use a CDN?- Content is delivered quicker-- Latency cut downPricing is granular - pay as you go type dealAmazon + Rackspace Cloud Files
  24. 24. How does it all fit together?
  25. 25. What happens when it all goes wrong?
  26. 26. Caching to the rescue!Each layer provides protection3rd Party - shield 99% of anon trafficVarnish - the restAnonymous users should never know your sitehas issues.
  27. 27. Debugging TipsConfigure different urls for different platforms- Easier to identify what cache layer has an issueDont be afraid to flush caches- Your backend should be able to cope with itAnalyse headers! Drupal and Varnish provide a lot of infoAkamai information can be gleaned from additional httpheaders.
  28. 28. Debugging TipsMonitor each layer- Icinga- Pingdom
  29. 29. Any Questions? Slide designs by Ritch Partridge (@ritchpartridge)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×