Weitere ähnliche Inhalte Ähnlich wie Enhancing scalability with intelligent caching (20) Enhancing scalability with intelligent caching2. 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.
3. Why am I here?
• Most caching is badly implemented
• Allow me to explain...
© All rights reserved. Zend Technologies, Inc.
4. Hey, it works!
• A new website is born...
Internet
LAMP Server
© All rights reserved. Zend Technologies, Inc.
5. ...or at least it used to work.
• the smoke begins...
Internet
LAMP Server
© All rights reserved. Zend Technologies, Inc.
6. No simple solutions
• 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
© All rights reserved. Zend Technologies, Inc.
7. Page Caching
• 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
© All rights reserved. Zend Technologies, Inc.
8. Page Caching
© All rights reserved. Zend Technologies, Inc.
9. Data caching
• 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
© All rights reserved. Zend Technologies, Inc.
10. Let‘s get controversial...
• 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
© All rights reserved. Zend Technologies, Inc.
11. One common architecture
• Network data cache
e.g. Memcache
Internet DB Server(s)
LB
Cache
Server
Web Farm
© All rights reserved. Zend Technologies, Inc.
12. Network data cache
• 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
© All rights reserved. Zend Technologies, Inc.
13. A different approach
• Shared memory cache Cache
e.g. Zend Data Cache, APC
Cache
Internet DB Server(s)
X
LB Cache
Cache
Server
Web Farm
© All rights reserved. Zend Technologies, Inc.
14. Shared memory cache
• 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)
© All rights reserved. Zend Technologies, Inc.
15. Demo...
The Great Cache Performance
Head to Head
© All rights reserved. Zend Technologies, Inc.
16. Shared memory cache
• 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
© All rights reserved. Zend Technologies, Inc.
18. Shared memory cache on steroids
• 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
© All rights reserved. Zend Technologies, Inc.
19. So long...
• …and thanks for all the fish.
© All rights reserved. Zend Technologies, Inc.