The Magento Mage_Cache_Backend_File backend gives some holidays for your inodes

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:

Screenshot of a cache folder content which use the Zend_Cache_Backend_File backend This is due to the way Zend_Cache_Backend_File store the cache content:

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:

Magento cache content folder when using the Mage_Cache_Backend_File coming from EE1.13

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)

ProjectCache usageCache configurationInode benefit usage with Mage_Cache_Backend_FileRequest per second benefit with Mage_Cache_Backend_File
Project 1BasicNo FPC, Memcached / file37%0,5%
Project 2EnhancedFPC, file30%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?