Description
Preconditions (*)
- Magento 2.3.3
- Redis Cache enabled
- Production mode
Steps to reproduce (*)
- Run Magento in Production with 15 Stores and organic trafic
- Redis caching enabled
Expected result (*)
- Redis cache will stabilize in size.
- Cache key expiery is set for all things that do have an expiery
Actual result (*)
- Redis is growing in size to unlimited (>30GB)
- Cache key expirey is not set
> info keyspace
# Keyspace
db0:keys=45775,expires=41711,avg_ttl=79567831
db1:keys=49089,expires=27837,avg_ttl=16355872
db2:keys=706,expires=706,avg_ttl=696476
Further information
The only way to prevent our production system server from dying was to set a hard limit for Redis memory consumption. The 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. This should be handled by the application with setting an resonable ttl.
fix
This is actualy an known bug and already long time fixed in an dependency of magento core composer file. See also colinmollenhour/Cm_Cache_Backend_Redis@bc63e72
But this is not included in current magento version Last update of this core depedency was in September 2018: 32058c7
Applying this change as a hotfix, actualy stabalize our production redis at 3,5GB ram usage, instead of growing over 30GB. And also boost the performance of the system quiete a bit.
Hot Fix
Add the following requirement to your project composer.json file:
"colinmollenhour/cache-backend-redis": "1.11.0 as 1.10.6"
Fix
I will File a PR with an updated composer dependency to the magento core and reference this issue.