Magento allows to customize the way your website manages its cache. This is done by choosing the appropriate cache backend. I’ve provided an example of this update for the full page cache here
By default, your cache will save cached content into files, due to a cache backend existing in both Magento community and enterprise editions, based upon the Zend_Cache_Backend_File, that saves cached content into files
Magento EE 1.13 comes with a new cache storage: Mage_Cache_Backend_File. This backend is an extension of the native cache backend Zend_Cache_File with some improvements regarding performances: Let’s see what is good inside and if we can use it yet
Resume on how are stored cache data in files with Zend_Cache_Backend_File backend
Prior to Magento enterprise 1.13 version, you can only use the default file backend, Zend_Cache_Backend_File. This backend saves cached content into a file in a cache directory which is by default the Magento folder var/cache
If you look inside the subfolders in it, you’ll see something like this:
when you save a cache content with this backend, you generate two elements:
- One file for the cached content
- One file for its metadata description elements:
- When the content will expire
- When the content has been built
- The cache tags related to cached content
Most of the common cache actions require in this model two hits: one for the metadata file, and one for the cached content:
- If you load a cache content, you’ll first load the metadata file content and after the cached content
- If you save a cache content, you need to create or update the metadata file and after that the cached content
- When trying to remove a cache content, you’ll first clean the cached content and after that the metadata files
- Cleaning some cache tags needs to read the metadata files in order to find matching cached content, and after cleaning can find the cached data
All these actions can lead to a very important inode usage.
Global inode usage reduction when using the Mage_Cache_Backend_File
If we look for a cache folder content after configuring Magento Mage_Cache_Backend_File usage, we can see that internal metadata files does not exist any more:
Now metadatas are saved in the same file as the cached content: so you divide per two inodes used and time to fetch data. On the same Magento website, I’ve checked the number of generated files in var/cache folder after having flushed cache folder (cache and full page cache folder)
|Project||Cache usage||Cache configuration||Inode benefit usage with Mage_Cache_Backend_File||Request per second benefit with Mage_Cache_Backend_File|
|Project 1||Basic||No FPC, Memcached / file||37%||0,5%|
|Project 2||Enhanced||FPC, file||30%||1,5%|
If your cache management is based upon files, this backend is for you a must have!
There was many feedbacks on the Magento enterprise 1.13 performances but this one was released silently…why? Such a shame not knowing that when updating one file in your Magento, you can reduce drastically inode usage and offer really better algorythms, don’t you think ?
I’ve tried it on further projects success.
And you, what is your feedback on this cache backend usage?