I recently worked with one of our Magento Enterprise Cluster clients who wanted to improve the performance of their site. This client was using our Content Delivery Network to offload the serving of static assets, and was following all of our recommended Magento Optimization best practices. They were also using Memcached as the fast-backend in their Magento configuration. Despite doing everything right in terms of optimization, we managed to shave considerable time off their time-to-first-byte by leveraging multiple instances of memcached and Magento’s terrific use of the Zend Framework for caching. Here’s how.
Whenever you configure a shared-memory type of caching backend — e.g. memcached, xcache, or apc — Magento will enable the Zend Framework’s TwoLevel cache type. The basic idea behind the two level cache is that you have a fast, limited-sized cache for the initial lookup and a slower, larger-capacity cache for when the fast cache lookup misses. The benefit of this is that you get the speed of a memory-based caching backend plus the capacity of a disk- or database-based backend. That is, when the two-level cache works as it should. Fabrizio Branca has an excellent writeup about the problems with Magento / Zend TwoLevel caching, along with a patch that can be used to fix some of them. I have implemented this patch on a few sites now and have seen significant improvement in first-level cache hits. Read more