enhancing scalability with intelligent caching

20
© All rights reserved. Zend Technologies, Inc. Enhancing Scalability With Intelligent Caching By Eric Ritchie ([email protected])

Upload: eric-ritchie

Post on 16-Jul-2015

352 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Enhancing Scalability

With Intelligent Caching

By Eric Ritchie ([email protected])

Page 2: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Eric Ritchie bids you welcome!

• Senior Technical Consultant and Trainer at Zend Technologies

• Zend Framework and PHP 5.3 ZCE

• Eighteen years of system administration experience

• Twelve years of PHP (3,4 & 5) and five years Zend

Framework development experience

• Hobbies: Sampling good wines/whiskies (gifts welcome)

Page 3: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Most caching is badly implemented

• Allow me to explain...

Why am I here?

Page 4: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• A new website is born...

Hey, it works!

Internet

LAMP Server

Page 5: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• the smoke begins...

...or at least it used to work.

Internet

LAMP Server

Page 6: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Migrating to web clusters:

Classical horizontal scaling

Complicates and imbalances application architecture

Moves bottlenecks over to the DB (usually)

• Scaling DB architecture:

Potentially expensive

Or complicates the application (sharding)

And/or replication issues

• Let‘s just cache something... That‘ll work

No simple solutions

Page 7: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Dramatic reduction in page delivery time

Reduces the need for expansive server farms

Quick and inexpensive (perhaps)

• But...

Custom data is problematic one way or the other

Complicates the application

Risk of delivering stale content

Dependency on caching usually a recipe for disaster

Page Caching

Page 8: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Page Caching

Page 9: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Protects the data layer:

Classical vertical scaling

Far easier than scaling the database

• But...

Requires code changes

Custom data is still problematic

Risk of delivering stale content

De-caching can bring down the database

Data caching

Page 10: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Caching is a divisive topic

• Let me share my experience of...

Providing a highly available cache

Providing a truly scalable cache

Providing a high performance cache

Preventing a run on the database

Ensuring fresh data resides in cache

• Remember, don‘t kill me!

This is not the only way

Let‘s get controversial...

Page 11: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Network data cache

e.g. Memcache

One common architecture

Internet

LB

Cache

Server

Web Farm

DB Server(s)

Page 12: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Some advantages

Only one cache to update/invalidate

Most effective way of protecting the data source

• Many disadvantages...

Single point of failure (or uncertainty when in distributed mode)

Limits scalability

Performance bottleneck

Slower

Network data cache

Page 13: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Shared memory cache

e.g. Zend Data Cache, APC

A different approach

Internet

LB

Cache

Server Web Farm

DB Server(s)

X Cache

Cache

Cache

Page 14: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Many advantages

Completely scalable (copy/paste architecture)

No single point of failure

Does not require TCP/IP

Very fast

• Some disadvantages...

Not the path of least resistance

More work for the data source and the developer

Your colleagues may laugh at you (but they would be wrong)

Shared memory cache

Page 15: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Demo...

The Great Cache Performance

Head to Head

Page 16: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Taming the disadvantages

True, we need to work a little, but...

• We can use Zend Server‘s Job Queue to perform remote

cache maintenance

• We can get a list of active servers from the Web API

provided by Zend Server

• Really, we don‘t have to code much ourselves

Shared memory cache

Page 17: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Distributed de-caching

• With Zend Server‘s Job Queue

• ...and the job itself

Page 18: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

• Don‘t decache, update

Regenerate the data and insert into the cache

At a minimum do this for all components of the index page

Reduces data source load

Shared memory cache on steroids

Page 19: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

So long...

• …and thanks for all the fish.

Page 20: Enhancing scalability with intelligent caching

© All rights reserved. Zend Technologies, Inc.

Enhancing Scalability

With Intelligent Caching

By Eric Ritchie ([email protected])