Using Redis with Magento 1.8+

Submitted by Eric on Sat, 03/24/2018 - 07:51
Redis Configuração

Redis is memory-based key-value. Imagine Memcache with more tools such as clustering and multiple databases.

Magento can use Redis to:

  • Session
  • Cache
  • Full Page Cache (Enterprise)

What is the reason to use Redis?

  • It is faster and more efficient for the Magento backend. Recommended by Magento and most of Magento developers.
  • It can be shared between multiple balanced servers and replaces the use of Memcache for the backend cache.
  • Redis can also be used for as opposed to Memcache, so the cache is in memory. Read here the explanation of why this is good:
  • Redis has persistence, whereas if you restart the memcache service you need to wait for a new cache.

And where should Redis be installed?

This will depend on the type of server you use, see examples:

  • Dedicated - Install Redis on the database server.
  • Dedicated Cluster - Redis can be configured as an RHCS service for HA.
  • Cloud - Install Redis on a server with plenty of free memory, usually the database. Another option is to use Redis-a-S. Li>
  • Single server - Still ideal to use if you have free memory. Use UNIX socket to remove TCP overhead. Li>

Installation and Configuration:

The first step is to check the version of your Magento, if it is CE 1.8+ or EE 1.13.1+ you can use Redis, if you do not use these versions you will need some module. Our example is only for versions EC 1.8+ and EE 1.13.1+.

The second step is to install and configure the Redis service. In our example we will install on the private IP database server Install Redis by running the following commands:

yum install epel-release
yum install redis
chkconfig redis on

Configure o arquivo /etc/redis.conf, preste muita atenção que está é uma parte muito importante.

Set up the  /etc/redis.conf file, pay close attention that this is a very important part.

First change the bind to the private IP of your server, in our case:


Let's change the configuration to use UNIX socket, for this uncomment the following lines:

unixsocket /tmp/redis.sock

unixsocketperm 755

In our case we only want memory cache, so we can disable disk persistence by commenting:

#save 900 1
#save 300 10
#save 60 10000

Something very important is that Redis was made for speed and not safety. Ideally, you should always use a private network or Cloud Networks. If you use a private network that can be seen by other users, let's set a password for Redis. It is recommended to create a large password because Redis speed facilitates a brute force. We will use this password:


Still in the same file add the password:

requirepass FlfTlU6bAJQBVTtPFqJxX4xWamcjnFn28VBQhN3THN1fitMGlm

Still editing the same file we will change some maxmemory information:

maxmemory 1500mb

maxmemory-policy allkeys-lru

Save the file and start the Redis service by running the commando:

service iptables save

Finally open the 6379  port with the command:

iptables -A INPUT -p tcp -m state –state NEW -m tcp –dport 6379 -j ACCEPT
service iptables save

Now that we have the Redis service running in our database, we will install the PHP module on your web server in the third step strong>. You can easily deploy by running the command:

yum install php-pecl-redis.x86_64 -y

After installation restart Apache/nginx.

The fourth and final step is the Magento setup. Open the app/etc/local.xml file and place the following information between the tag: <gloal>:

  • Sessões (


  • Cache (


  • Full Page Cache (Enterprise somente) (


Now that we have configured the local.xml, we will activate the Redis module for Magento, so open app/etc/modules/Cm_RedisSession.xml file and change false to true.