Redis fills up with upstream recommended eviction policy because expires isn't set on cached keys. #21
-
Unless you use allkeys-lru as an eviction policy, redis fills up with un-evictable keys when sites are spidered heavily, or when using cache preloading in a page caching plugin. DescriptionSince the plugin docs do not cover redis config, users refer to upstream, who say:
Unfortunately though, this won't work for redis-cache since entries do not expire. Worse still, the end result is a 500 error white screen of death on page loads if a page cache is active (e.g. WP Rocket). Rather than let this happen, if the cache entries were set to expire=true, then things would auto-work for most use cases with the defaults. Expected BehaviorOne should be able to enable the plugin with default settings and have it just work (and stay working) Actual BehaviorInstead, once a site is spidered heavily (or cache preloaded by wp rocket), the next page load 500's with error. This takes down not only the site but WP CLI as well. This is due to WP Rocket trying to cache a new page and failing. Here is an example from a recent site outage:
Unfortunately this combination of WP Rocket + Redis Cache + full cache manifests as a WSOD ;( Possible Fix
Steps to Reproduce
Additional contextMultiple outages on production site turned out to be this issue.. had real trouble finding accurate info. Would be great if it "Just worked" as its hard to recover from for a novice. Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There is no default maxTTL, did set a Also, the maxTTL does not protect against Redis Server running out of memory if your system is limited in memory, so setting a |
Beta Was this translation helpful? Give feedback.
-
Hi @tillkruss , No, a Max TTL is not set and that is not something that you want to set necessarily, there is no reason objects should be purged if the cache isn't out of memory. There is a difference between: "expires" in Redis and TTL. "expires" is a boolean (true/false flag) which tells Redis that you are making a cache entry that is volatile (i.e. it can be purged when the cache is full, according to maxmemory-policy. When you set an entry with expires=false, you are telling redis it's a permanent entry and not to purge it with 'volatile-lru' (the default setting). Further to that, you have no exception handling on the cache set, so the plugin's misconfiguration is causing total site failure (whitescreen of death as well as dead WP CLI). That is also a bug, there should be try / catch exception handling there so that a cache fail is not a fatal error.
those are both bugs, not discussion points. They break sites in default configuration and that is easily avoidable with very minor fixes. thank you, D. |
Beta Was this translation helpful? Give feedback.
There is no default maxTTL, did set a
WP_REDIS_MAXTTL
constant?Also, the maxTTL does not protect against Redis Server running out of memory if your system is limited in memory, so setting a
maxmemory-policy
is recommended.