Caching Layers
- $GLOBALS
- APC
- Memcached
- Database
- Browser Cache
- Third Party CDN
- Avoids unnecessary APC and Memcached requests
- Automatic via abstraction
- But still has function call cost overhead
APC
Opcode caching
‣ Hundreds of included libraries
‣ Thousands of functions
Variable caching
‣ Hundreds of MB’s of data
APC Cache
Non-user specific data
‣ Network/School information
‣ Database information
‣ Useragent strings
‣ Hot application data
‣ Site variables
APC Opcode Priming
APC+SVN Client Cache Busting
APC + Useragent Strings
Useragent string parsing is inefficient in PHP
Cache parsed useragents in APC for the first 10 minutes
Hit rate of over 50%
Pear implementation available:
‣ PEAR::Net_Useragent_Detect_APC
Site Variables
- Enable/Disable site features across all servers
- Configure memcached cluster IP’s
- Configure product features
- Version memcached keys for invalidation
Memcached
- Distributed object cache
- Facebook currently utilizes > 400 memcached hosts
- With > 5TB in memory cache
- Facebook contributions:
‣ Performance Enhancements
- Many choices in opensource clients
- Memcached PHP extension
‣ Socket blocking in C instead of userspace PHP
‣ UDP support
UDP Memcached
- TCP Limitations
‣ Impedes scalability of memcached clusters
- Requires a very stable network environment
- Occasional misses are acceptible
- Reduces kernel buffer memory usage on clients and servers
No comments:
Post a Comment