Redis

Redis

Redis is a scalable high-performance key-value store that can be used as a cache backend for Magento. It has been tested on high traffic Magento stores with over 500.000 visitors per day. Recently Byte has made it’s platform suitable for Redis. In this blogpost I will show you why Redis is superior to Memcache. And I will also give you an offer you cannot refuse.

TwoLevel cache in Magento

Let’s start with some introduction on Magento caching and the Zend TwoLevel cache system;

Magento caches certain data to speed up page load time. There are several backends you can choose from to store this cache in. Most commonly used are the (default) file-cache and Memcache. For multi-node stores, which usually use NFS (network file system), disk access is slow and cannot handle many concurrent requests. Memcached however stores its data in-memory, which is fast … in theory.

Memcache lacks one trivial feature that Magento uses; the feature to store tags. You could compare a tag to a category grouping several keys/values together. When using Memcached, Magento has to store the tags in file-cache to maintain its tag support (hence the two levels).

Redis does support tags out of the box. By using Redis you won’t need the file-cache anymore. After switching to Redis as cache-backend, you can clean up your /var/cache directory and you will notice it stays empty! All cache data is now being served from memory.

 

Redis cached zowel de Tags als Key Values in het geheugen.

Redis: both Tags and Key Values are cached in memory.

 

Redis outsets Memcache

When you are working in the Magento backend, or you are a customer adding products to your shopping cart, Magento will have to flush certain bits of the cache after your actions. 

Let’s say you’re editing product data in your backend, or you are a customer filling your cart with products. For some of your actions, Magento has to invalidate/flush a certain part of the cache. The keys & values that belong to that part are defined by their tag. 

Suppose you use Memcached as backend storage, and you have to flush the tag “STORE_GR”. The tags are obviously not in Memcached, so Magento starts looping over every cache entry in the /var/cache folder and retrieves the tag-data from the entries. Next step is to unserialize that tag-data, see if it contains the previous “STORE_GR” tag and so on for every entry in the cache.

You can imagine that this could be considered “not optimal”. It is a time consuming operation, which is only going to be slower for every additional product you have in your store.

Redis is supporting tags out of the box, which makes it lots faster for tag-related operations. You can just ask Redis “give me all keys that are related to tag STORE_GR” and Redis will return a list of keys. So if you’re working in the Magento backend regularly, I would always insist on using Redis.

Redis and Full Page Cache?

Full Page Caching speeds up your website quite a lot, because categories and products can be cached too. This however triggers the above problem even more, because almost for every change in the backend it will have to invalidate parts of your cache. The ideal solution there would be to store the FPC in Redis too. 

Using FPC with Redis is however a bit tricky, as there are (as far as I know) no FPC-extensions for the community edition supporting Redis so far. I expect that FPC extensions (like Zoom FPC) will offer support for Redis soon. For now, Enterprise FPC is however supported by the Redis module, so if you are one of the lucky few who can afford Magento Enterprise, you can use FPC with Redis.

Update 15-05-2013: Today Gordon Lesti released a new version of his (free) FPC extension with Redis support. Check it our at https://github.com/GordonLesti/Lesti_Fpc

Test Redis for free at Byte hosting

Since January we are using our brand-new Redis platform with a few large early adopter Magento stores, both Community and Enterprise edition. In the future Redis will also be available for our Clusterplatform. We would like to make everyone as enthousiastic about Redis as we are. That’s why we offer Magento sites to test Redis for free till 14th July this year (Red. testperiod has expired). Interested? Just order the Building Block on your Service Panel or if you are not a Byte customer yet: contact us via support@byte.nl!

 

 

Scan je eigen Magento shop op veiligheidslekken