caching demystified
play

Caching Demystified presented by Aaron Welch and C a c h i n - PowerPoint PPT Presentation

Caching Demystified presented by Aaron Welch and C a c h i n g D e m y s t i f i e d A a r o n W e l c h C a d r e W e b H o s t i n g What is a cache? A cache is a mechanism that allows you to


  1. Caching Demystified presented by Aaron Welch and C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  2. What is a cache? A cache is a mechanism that allows you to store data that can be re-used later. Common aspects of cache mechanisms include: - store non-persistent data (will be destroyed at some point) - depending on the type of cache, data can be cached as it is passed through the cache mechanism or stored and retrieved on request within an application - provide some sort of interface to manually destroy all or part of the cached data C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  3. When are caches used? - Many repeated operations - Expensive operations C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  4. Why are caches used? Volume (support more requests, eg: people or traffic) Performance (go faster) These things are not mutually exclusive; working to improve one, you generally get improvements on the other as well C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  5. Opcode Caches Caches PHP bytecode after being compiled, then executes that instead of re-compiling on every request. Examples: APC / eAccelerator / Zend Optimizer C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  6. Opcode Caches apache/upstream poop PHP Script Execute Opcode Cache YES (valid cache?) NO Parse Compile Store in cache C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  7. Opcode Caches Benefits: • Generally solutions are drop-in (high benefit with low integration cost) • Generally provide other PHP optimizations Drawbacks: • Do not generally help with application level problems like poorly written mysql queries or large memory footprint • Do not help with page rendering speed in the browser • Do not directly help with scaling volume in apache, only cache the php scripts – not anything generated by them C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  8. Proxy Caches Stores content delivered by the application (Drupal/Apache) and serves subsequent requests from cache instead of passing the request back to the application. Examples: Varnish / Ngnix / Squid C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  9. Proxy Caches browsers! internets! Proxy Cache Deliver from Cache Deliver Request YES (valid cache?) NO Store in cache LAMP / Drupal generates response C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  10. Proxy Caches Benefits: • Removes the thread limitations of apache (scaling) and reduces load from Drupal / LAMP stack (performance) • Very high benefit, low resource requirement compared to Drupal alone Drawbacks: • Moderate to high integration cost • Can make development/content management more difficult/confusing for developers/users • Only effective for unauthenticated users Tools: www.isvarnishworking.com to verify varnish C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  11. Object Caches (name/value stores) Stores an object in memory by name, and returns that object on request later (name/value object store) Examples: memcache / membase / redis C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  12. Object Caches (name/value stores) Benefits: • Extraordinarily performant • Can drastically reduce database load for high transactional volume operations on tables with non-persistent data (sessions, cache tables) Drawbacks: • High integration cost • Can make development/content management more difficult/confusing for developers/users • Can be insecure if not protected (no auth mechanism) • Only helps with in-application bottlenecks (does not reduce memory footprint of the application itself) • C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  13. Edge Caches A network of servers that store requested assets in cache, and deliver them in a geographically relevant way Examples: Akamai / Amazon cloudfront / Voxel CDN (voxcast) C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  14. Edge Caches browsers! internet! CDN Deliver from Cache Deliver Asset NEW YORK CHICAGO ELKO Store Asset in Cache YES CDN Origin NO Asset valid in cache? (your server) C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  15. Edge Caches Benefits: • Massively scalable • Reduces the number of requests for static assets on the web server • Can increase page rendering speed in the browser • Easy to setup (not a local service) Drawbacks: • Not effective for low-volume sites (assets expire before enough requests are served from cache to be effective) • Can be problematic to integrate with the application • Can make development/content management more difficult/confusing for developers/users C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  16. Others Browser Database Server (internal) Boost DNS C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

  17. Questions? Yay! There is: www.getcadre.com C a c h i n g D e m y s t i f i e d A a r o n W e l c h – C a d r e W e b H o s t i n g

Recommend


More recommend