enhancing scalability with intelligent caching
TRANSCRIPT
© All rights reserved. Zend Technologies, Inc.
Enhancing Scalability
With Intelligent Caching
By Eric Ritchie ([email protected])
© 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)
© All rights reserved. Zend Technologies, Inc.
• Most caching is badly implemented
• Allow me to explain...
Why am I here?
© All rights reserved. Zend Technologies, Inc.
• A new website is born...
Hey, it works!
Internet
LAMP Server
© All rights reserved. Zend Technologies, Inc.
• the smoke begins...
...or at least it used to work.
Internet
LAMP Server
© 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
© 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
© All rights reserved. Zend Technologies, Inc.
Page 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
© 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...
© All rights reserved. Zend Technologies, Inc.
• Network data cache
e.g. Memcache
One common architecture
Internet
LB
Cache
Server
Web Farm
DB Server(s)
© 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
© 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
© 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
© All rights reserved. Zend Technologies, Inc.
Demo...
The Great Cache Performance
Head to Head
© 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
© All rights reserved. Zend Technologies, Inc.
Distributed de-caching
• With Zend Server‘s Job Queue
• ...and the job itself
© 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
© All rights reserved. Zend Technologies, Inc.
So long...
• …and thanks for all the fish.
© All rights reserved. Zend Technologies, Inc.
Enhancing Scalability
With Intelligent Caching
By Eric Ritchie ([email protected])