Contributed by Ravi Petlur on 2 May 2013
Earlier, we looked at how Varnish can help speed up the performance of Magento. In this blog, I will be explaining how Magento sessions work and how we can configure Redis as a back-end for session storage.
Magento uses the default two-level caching of Zend framework. It is configured in the Local.xml file of Magento. Basically, it uses one fast and one slow caching method. The fast cache can be configured to APC/Memcache whereas the slow one is based on a file system.
By default, Magento stores its cache entries in the file system. You can find the cache in var/cache/. This cache back-end is fine for small websites with a small cache size. As you get more requests from visitors, reading and writing to the file system gets slower and slower as the cache grows. The Magento cache is organized by tags, this means we have cache entries that belong to a cache group.
It works by default. We don’t need to install additional software.
Disadvantages:
Magento clears cache entries by tag. For e.g. after placing an order or saving a product to make sure the block caches are updated on the store. While clearing entries by cache tag, Magento has to open each file to check if the cache entry belongs to the cache group. If we have a Magento shop with >= 1000 products, you will have a cache size of > 50 MB. A 50MB file system cache has about 3500 entries (files). We can deduce that this is very slow.
1. Use an SSD instead of normal hard disk
2. Put the var/cache directory in tmpfs
The primary advantage of using Redis cache is that cache tags are supported. We don’t need to use the slow-level file system cache anymore. This Magento cache back-end is highly recommended in multi-server environments where you have more than one web server.
Advantages
Requirements:
- Redis must be installed on the server
- PHP Extension - PHPRedis must be installed
- Magento extension “Cm_Cache_Backend_Redis” must be installed
1. Install redis (2.4+ required)
2. Install phpredis
3. Install the Magento extension “Cm_Cache_Backend_Redis”
4. Edit your app/etc/local.xml file as shown below:
Restart the PHP process and you should be able to see the cache being stored in Redis as shown below
Next up, we will be running some benchmarks on this. You will see the difference in performance of Magento.
Check out how we successfully implemented Varnish cache and Redis session techniques to improve site performance for GPPGolf, a leading US-based Golf retailer.
Also, take a look at our Magento capabilities here.
You may also find the following blogs related to Magento interesting;
Visit us at Neevtech.com to know more about our offerings.
Tags: magento, Magento Performance, Redis
© 2015 Neevtech Blog | Neev Technologies
Leave a Comment