In this competitive world where website performance is measured in milliseconds and not seconds, configuring your Magento store for peak performance is essential. Consumers in the online world have become increasingly impatient, and slower response times can affect conversion rates. If you suffer from slow Magento performance, we have the solution. Below, we have very briefly highlighted how Redis can be used to improve Magento performance.
First, let us review how Magento works. Magento uses the default two level caching of the Zend framework, a fast cache and a slow cache, as configured in the Local.Xml. The fast cache is configured in APC/Memcache and the slow one is configured in the file system. The default model (default two level cache) however, proves to be a disadvantage rather than an advantage. This is because Magento stores all its cache entries in the file system in var/cache folder, the process of storing cache in the file system is fine as long as traffic to the store is minimal, but once the traffic to the store increases, the number of cache entries in the file system increases and the reading & writing process to the file system becomes slower.
Magento clears its cache entries by tag. A typical situation is one where, after placing an order or saving a product, it makes sure that block caches are updated on to the store. While, in the entire process of clearing entries by cache tag, Magento has to open each file to check if the cache entry belongs to the cache group. Imagine a store with 2,000 products; it would have a cache size of 100 MB. There would be at least 6,000 entries or individual files and the process would be very slow — certainly not feasible in the long run. So, it’s better to think of an another alternative of caching to increase the performance of Magento.
Introducing Redis (Next-Generation cached backend) — an open-source, scalable, high-performance key value store that can be used as a cache backend for Magento. It is referred to as a data structure server since keys can contain strings, lists, hashes, sets & sorted lists. Redis has already been tested on high-traffic Magento Stores with over 500,000 visitors per day. Let us discuss how Redis is superior to Memcache in a little more detail.
Redis outsets with Memcache
Let’s say you’re editing product data in the Magento backend, wherein Magento has to invalidate certain part of the cache. The keys & value that belong to that part are defined by their tag. Now suppose you use Memcache as backend storage and you have to invalidate the tag “store_GR”. These tags are not in Memcache, so Magento will start looping over every entry in the /var/cache folder and retrieve the tag-data from the entries. This entire process is time-consuming and going to be slower for every additional product you have in your store.
Redis is far ahead in supporting tags, which makes it much faster for tag-related operations. You can just ask Redis to give 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, Redis will be the best option to work with.
Redis supports full page caching
Full page cache reduces latency, increases request per second, reduces load on database and simply make your e-commerce site more responsive. A cache is only effective as long as there are cached items. Normally a full page cache must be flushed after changes have been made to products, categories, and cms pages. This is inefficient because changing one product can invalidate the entire cache. Redis supports auto-tagging and auto-flushing, so that whole cache flushes rarely ever need to be done. After you edit a product, all pages associated with that product will be flushed and the others will be unaffected.
Benefits of Redis
- Fast cache backend with excellent support for cache tags
- Efficient in multi-server environments
- Rich API and low latency
- Zero downtime
- Suitable for high-traffic Magento stores with more than 500,000 visitors a day
- Using Redis as a caching backend reduces overhead and improves performance