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

caching demystified
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Caching Demystified

presented by

Aaron Welch

and

slide-2
SLIDE 2

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

What is a cache?

slide-3
SLIDE 3

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

  • Many repeated operations
  • Expensive operations

When are caches used?

slide-4
SLIDE 4

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

Why are caches used?

slide-5
SLIDE 5

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Caches PHP bytecode after being compiled, then executes that instead of re-compiling on every request.

Examples: APC / eAccelerator / Zend Optimizer

Opcode Caches

slide-6
SLIDE 6

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Opcode Caches

Execute Opcode Cache (valid cache?) Compile Parse

apache/upstream poop

PHP Script YES NO Store in cache

slide-7
SLIDE 7

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

Opcode Caches

slide-8
SLIDE 8

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

Proxy Caches

slide-9
SLIDE 9

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Proxy Caches

Deliver Request LAMP / Drupal generates response

browsers! internets!

Proxy Cache (valid cache?) YES NO Store in cache Deliver from Cache

slide-10
SLIDE 10

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

Proxy Caches

slide-11
SLIDE 11

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Stores an object in memory by name, and returns that object on request later (name/value object store)

Examples: memcache / membase / redis

Object Caches

(name/value stores)

slide-12
SLIDE 12

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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)

  • Object Caches

(name/value stores)

slide-13
SLIDE 13

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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)

slide-14
SLIDE 14

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Edge Caches

Asset valid in cache? Deliver from Cache

ELKO CHICAGO

CDN Origin (your server)

NEW YORK

CDN YES

browsers! internet!

Deliver Asset Store Asset in Cache NO

slide-15
SLIDE 15

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

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

slide-16
SLIDE 16

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Others

Browser Database Server (internal) Boost DNS

slide-17
SLIDE 17

C a c h i n g D e m y s t i f i e d A a r

  • n

W e l c h – C a d r e W e b H

  • s

t i n g

Questions?

Yay! There is:

www.getcadre.com