Bobcares

Magento Redis cache – How it improves website speed

by | Jul 30, 2019

Are you sick and tired of slow loading Magento websites?

Using Redis cache is one of the best ways to improve Magento website performance.

However, enabling Magento Redis cache involves setting up the Redis server and configuring it. This often requires tweaks in cache management too.

That’s why we receive customer requests to setup Magento Redis cache as part of our Server Management Services.

Today, we’ll see how Bobcares Engineers enable Magento Redis cache and make the website faster.

How Redis helps in making Magento faster?

Before proceeding further, let’s take a quick look at how Redis helps to make Magneto website faster.

By default, fetching content from cache aka high-speed memory helps to load the web page faster. The same is applicable for Magento websites too.

Fortunately, Redis is an open-source key-value store available for use in Magento for back end and session storage. It supports PHP session storage, on-disk save, etc.  Moreover, It can cache the database values, resulting in less database resource usage, On the whole, Redis provides a tunable persistent cache.

It’s now time to see how Redis actually works. When loading a web page for the first time, there will be a database query on the server. Redis caches the query. And, when another user loads the same page, the server provides the results from the Redis without querying the actual database. As a result, the page loads faster.

 

Steps to enable Magento Redis cache

Till now, we saw how Redis actually helps in making Magento website faster. Let’s check on how our Dedicated Engineers enable Redis on Magento.

Installing Redis involves two steps. First, we set up the Redis servers and second PhpRedis extension that allows PHP to communicate with Redis.

 

Installing Redis server

Here, our Dedicated Engineers set up the Redis server first. The exact steps for installation depend on the server type.

For example, on a CentOS server, the commands to setup Redis server and PHP extension are:

yum install redis php-pecl-redis
chkconfig redis on
service redis start
service httpd restart

Likewise, to update and install Redis-server on an Ubuntu machine, we use apt-get command.

After setting up, we verify the Redis server using:

redis-cli ping

When we receive a PONG response, we proceed with the Magento configuration to use Redis.

Similarly, to see if Redis extension is loaded by PHP, we grep the output of php -m shell command:

php -m | grep redis

 

Configuring Magento website

Further, we activate the Redis module by editing the Magento file at  /magento-folder/app/etc/modules/Cm_RedisSession.xml

The next step is to configure the Redis session model to use the database. For this, we edit the file inside app/etc/local.xml.

We, then proceed to clear all the cache and sessions in Magento using the commands:

rm -rf /var/www/html/magento/var/session/*
rm -rf /var/www/html/magento/var/cache/*

Or, we clear cache from the Magento Admin panel too. Here, we login as an administrator, access System > Cache Management and, click on ‘Flush Magento Cache’.

Finally, we restart Redis server as,

service redis-server restart

That completes the Magento Redis cache setup.

 

Frequent errors with Magento Redis setup

At times, the Magento Redis cache setup creates problems with live Magento Websites. We’ll now see the top Redis cache errors and how our Dedicated Engineers fix them.

 

1. Redis server not working

Recently, one of our Magento customers reported a site connection failure. The error said:


On a detailed check, our Support Engineers found that Redis stopped running on the server from an OOM kill. The server also had memory errors. To fix the problem, we restarted the Redis server and the site began running again.

Further, to avoid such errors in the future, we set up monitoring for Redis on the server. The status check of Redis appear as:

 

2. Redis version upgrades

Similarly, wrong Redis versions can create problems with Magento websites. And, it results in caching errors like:

main.CRITICAL: exception 'Exception' with message 'Warning: Redis::pipeline(): Already in pipeline mode

When a customer reported this error, we first confirmed that the server has a php-Redis extension installed. But, the PHP Redis version had upgraded automatically. However, the PHP-FPM was not restarted after the upgrade. So in phpinfo, it was still showing the old version and created conflict with Magento installation.

To fix, we had to downgrade php-redis and restart PHP-FPM on the server.

[Trouble enabling Redis cache for your Magento website? Our Magento Experts take only a few minutes to fix it.]

 

Conclusion

In short, enabling Magento Redis cache improves Magento website performance. It involves installing the Redis server and configuring Magento to use it. Today, we saw how our Dedicated Engineers make the Magento website use Redis cache and fix common errors with it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.