Magento / Web Apps

Redis Configuration for Magento 1.9.x

by , , revisited on

We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

Sanity check

In case you have a single Magento server, you should not be concerned with Redis most of the time. It is more efficient to mount sessions and other caches to RAM (in most Linux`es, you can). Introducing Redis in a single-server setup brings nothing in comparison to memory-mounted caches, only additional protocol overhead.


Naturally, you have to install Redis server first. You have to install Redis PHP extension as well.

Each Redis cache instance should use different database number to avoid naming conflicts. Take note of db parameter in the XML and increment it appropriately. In our configs below, we save PHP sessions in Redis DB with number 0, whereas storing the basic Magento cache in DB with number 1, etc.

Store Magento PHP sessions in Redis

I’ve seen it many times how disk stored sessions made websites crawl. How? A misconfigured PHP session garbage collector left millions of session files lying around. Listing the sessions directory took minutes. This would never happen if it was stored in RAM. It is much faster access-wise.

This part activates session handling by Redis.
Inside <config><global>..</global></config> section of app/etc/local.xml, put the following:


While the bot_lifetime controls the duration of session for bots, few of them use a session at all, but end up creating it for every request.
Thus you may want to consider a module to disable session creating for bots.

Store Magento configuration cache in Redis

This activates general Magento cache (modules configuration, etc.) to be stored in Redis.


Store Lesti FPC cache in Redis

Install Lesti FPC and put the following to app/code/etc/fpc.xml:

<?xml version="1.0"?>
            <!-- please read https://github.com/colinmollenhour/Cm_Cache_Backend_Redis for more informations -->

Confirm Redis is being used by running redis-cli monitor.

PotatoCommerce FPC full example

The following example demonstrate the best performance configuration, utilizing Redis cache using socket for sessions and all cache types. This uses a Redis instance on the same machine with Magento files (thus makes use of Unix sockets).

Note that putting port in the above config is still required to avoid getting ERR (3): Notice: Undefined index: port error logged to your system.log.

See the quick sanity check at the beginning – you still need another Magento server instance, otherwise you don’t need Redis after all.

  1. Lewis Seals

    Instead of config.xml I think it should be local.xml located /app/etc

    • Danila Vershinin

      You’re absolutely right. I’ve made the correction.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: