Magento 2.3.3 Redis cache grows unlimited

Introduction

Recently, one of our customers had troubles with redis-cache on his production multistore with 30 stores on it. His Redis became unavailable from time to time. We start to monitor it and found that there were too many expired Redis keys inside the database. Example of output:

> info keyspace
# Keyspace
db0:keys=45775,expires=41711,avg_ttl=79567831

Possible fixes

The possible way to prevent system server from dying was to set a hard limit for Redis memory consumption. Relying on the memory limit of Redis has some performance impact and there are always things cleared that don’t need to and vice versa. So, This should be handled by the application by setting a reasonable TTL.

We’ve fixed the following issue with upgrade redis-cache to the newest version with an update composer.json

"colinmollenhour/cache-backend-redis": "1.11.0 as 1.10.6"

Perfmanent fix

Also, a fix for this issue will be released in Magento 2.3.4. Link: https://github.com/magento/magento2/pull/25488

Conclusion

Alway use the latest software releases to prevent such kind of bug. Especially, such as Magento.

Related Post