How to Use Redis with Magento Community Edition (CE) and Enterprise Edition (EE)

Contents

Overview

Redis is an open source, Berkley Software Distribution (BSD) licensed, advanced key-value store that can optionally be used in Magento for back end and session storage. In fact, you can replace memcached with Redis.

Following are some of the benefits Redis provides for Magento implementations:

  • Redis supports on-disk save and master/slave replication. This is a powerful feature not supported by memcached. Replication enables high availability by eliminating a single point of failure.
  • Redis can be used for PHP session storage.
  • Redis provides much better eviction control and its back end is written with eviction support in mind.
  • Redis supports multiple databases that use the same server instance so you can use different databases for the Magento cache, full page cache (EE only), and sessions without starting many processes listening on different ports.
  • Redis supports compression libraries gzip, lzf, and snappy. lzf and snappy are much faster than gzip.
  • Limits the number of concurrent lock requests before an HTTP 503 (Service Unavailable) error is returned.

Requirements for Using Redis with Magento

The following Magento editions support Redis session and back end caching:

  • Enterprise Edition (EE) 1.13 and later
  • Community Edition (CE) 1.8

The preceding Magento editions support Redis server version 2.6.9 and later available from redis.io.

In addition, you can optionally use the Redis extension for PHP version 2.2.3 or later if you're using Redis for back end caching; however, Magento works without this extension.

Configuring Redis

To use Redis with Magento, you must configure Magento to use Redis and you must install and configure the Redis server. These tasks are discussed in the following sections:

Configuring Magento To Use Redis

To use Redis with Magento, you only need to install and configure the Redis server. The integration between Redis and Magento is already included with Magento CE 1.8 and EE 1.13 and later versions. All you need to do is configure it.

Important: The Cm_RedisSession module in CE 1.8 is disabled by default. Magento disables the module to avoid unnecessary connection tries to Redis when you choose to use file, database, or a different session storage method.

To enable Magento to use Redis, perform the following tasks:

  1. Enable the Cm_RedisSession module.
    1. Open magento-install-dir/app/etc/modules/Cm_RedisSession.xml in a text editor.
    2. Change the value of <active> to true.
    3. Save your changes to Cm_RedisSession.xml and exit the text editor.
  2. Modify magento-install-dir/app/etc/local.xml.
    For configuration information, see the sample provided with Magento in magento-install-dir/app/etc/local.xml.additional and also see the Readme (session) and Readme (back end).
  3. Flush the Magento cache in any of the following ways:
    • If you have access to the file system as the owner of the files in the Magento installation directory, change to that directory and enter rm -rf var/cache.
    • Log in to the Admin Panel as an administrator. Click System > Cache Management, then click Flush Magento Cache at the top of the page.

Installing and Configuring the Redis Server

Get Redis server version 2.6.9 or later and configure it according to their documentation.

You can optionally install the Redis extension for PHP version 2.2.3 or later as well, but Magento functions without it.

Getting Support for Redis

Important: Colin Mollenhour, the original author of Redis, does not provide support for Magento implementations. You can get support for Magento implementations in the following ways:

Magento edition How to get help
Magento CE and Magento EE
Magento CE Submit bug reports
Magento EE only Submit bug reports

For More Information

For more information about using Redis with Magento, see:

Acknowledgement

Magento acknowledges the contributions of Colin Mollenhour in providing the code for the Magento implementation of Redis.

Discussion:

Explore the Knowledge Base