Using and (slightly) abusing APCu cache in high load concurrent environments
summary
APCu is used as a local PHP in-memory cache to cut DB reads and achieves roughly ~500 requests/sec fewer queries but forces careful tuning: split huge arrays into per-key entries, implement per-feature key prefixes and a stored index to flush segments, and raise entry_hint to 250000 plus more shared memory to avoid evictions. Using APCu as a durable store breaks availability; fix required adjusting entries and memory and yields about 7–9% latency reduction with CPU rising ~3–7%.
AI-written summary · about
chapters (22)
- 0:00Introduction to APCu caching
- 1:03What is APCu and its benefits
- 5:24APCu in concurrent environments
- 7:54Choosing cacheable data
- 10:46First attempt and failure
- 16:09Data selection for APCu
- 17:37Why APCu shouldn't be a store
- 19:03First deployment results
- 20:30APCu memory usage issues
- 21:33CPU spike from deserialization
- 24:51Fixing the CPU problem
- 25:54Database latency increase
- 27:21Memory calculation mistakes
- 28:03Understanding APCu memory settings
- 31:17Setting entry hints correctly
- 33:29Final results and summary
- 36:10Q&A: Protobuffers vs APCu
- 37:57Q&A: APCu serialization
- 38:40Q&A: Performance comparison
- 40:11Q&A: Redis cluster setup
- 40:54Q&A: APCu failure impact
- 42:39Q&A: Metrics in APCu
related talks
01h 04mCaching Best Practices
18mCakePHP cache engine analysis
01h 01mPHP Opcache Explained
56mPHP OPCache, Realpath Cache and Preloading
01h 02mSpeeding up the Web with PHP 7
39mPHP Performance Demystified - Measure, Understand, Optimise
24mCaching Strategy for High Volume Personalized Content Requests
48mBuilding Really Fast Applications
