How to fix Redis in Magento 2

- E-Commerce, Magento 2

Magento 2 export CLI

If the Redis service crashes, it causes the performance downgrade of a Magento 2 website. In the following article, we shed light on the most common background of the issue. Besides, you will find out how to fix Redis in Magento 2. For further useful tips, follow this link: Magento 2 Cookbook.

'

Issue

All versions of Redis are affected. As for Magento 2, this guide is aimed at Magento Commerce and Cloud 2.2.x and above. If you experience website slowness or outage, it is probably caused by a memory overflow in Redis that, in its turn, causes the service to crash. The unpleasant situation is typical for peak time. Redis requires more memory than it is currently allocated. The lack of resources leads to the crash.

Solution

First of all, you need to discover what the current Redis configuration. Secondly, find out how much memory is used. Use the following CLI command: 

The command provides information regarding the following parameters:

  • used memory;
  • Maxmemory;
  • evicted keys;
  • Redis up time in days.

Note that you can retrieve the REDIS_PORT and REDIS_HOST variables from app/etc/env.php.

Depending on the output from running the above query, you should contact Magento Support with different questions:

  • If the amount of free memory is not more than 40%, request an increase of the maxmemory setting for your Redis Server. 
  • If the Redis up time is 0 days or the evicted keys value is not “0,” ask Magento Support to fix the issue.

You can find some related materials here: Redis service crashed.

'