pantheon-systems / wp-redis

WordPress Object Cache using Redis.
https://wordpress.org/plugins/wp-redis/
GNU General Public License v2.0
225 stars 67 forks source link

Large response size #440

Open elmeligy opened 1 year ago

elmeligy commented 1 year ago

Hi support

I am having multiple errors in my log saying that connection to redis timeout

I am using bitnami WP image hosted on a k8s cluster on Azure , I am using Redis cache service from Azure

I opened a ticket with them regarding this error , and they said it is caused by Large response size detected

how can I set this up from the plugin? I cannot find any options for the plugin?

what is the recommended settings for this?

please help me fix this ASAP

waiting for your feedback.

sample error log (I scrambled the personal data) :

2023/06/18 08:39:17 [error] 246#246: *854148 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RedisException: read error on connection to server-name.redis.cache.windows.net:6379 in /opt/bitnami/wordpress/wp-content/object-cache.php:1275

10.244.2.17 - - [18/Jun/2023:08:39:17 +0000] "GET /wp-json/name/v1/jsonld/meta/wl_schema_url?meta_value=https%3A%2F%2Fwww.example.org%2Fsample-product HTTP/1.1" 500 2738 "-" "ReactorNetty/1.0.25" "172.70.110.9"

#0 /opt/bitnami/wordpress/wp-content/object-cache.php(1275): Redis->get()

#1 /opt/bitnami/wordpress/wp-content/object-cache.php(655): WP_Object_Cache->_call_redis()

#2 /opt/bitnami/wordpress/wp-content/object-cache.php(137): WP_Object_Cache->get()

#3 /opt/bitnami/wordpress/wp-includes/option.php(1489): wp_cache_get()

#4 /opt/bitnami/wordpress/wp-includes/option.php(1351): get_network_option()

#5 /opt/bitnami/wordpress/wp-includes/ms-load.php(38): get_site_option()

#6 /opt/bitnami/wordpress/wp-settings.php(394): wp_get_active_network_plugins()

#8 /opt/bitnami/wordpress/wp-load.php(50): require_once('...')

#9 /opt/bitnami/wordpress/wp-blog-header.php(13): require_once('...')

#10 /opt/bitnami/wordpress/index.php(17): require('...')

#11" while reading response header from upstream, client: 10.244.2.17, server: _, request: "GET /wp-json/name/v1/jsonld/meta/wl_schema_url?meta_value=https%3A%2F%2Fwww.example.org%2Fsample-product HTTP/1.1", upstream: "fastcgi://unix:/opt/bitnami/php/var/run/www.sock:"

Azure Answer :

Large response size detected

Responses from this cache exceeded recommended size limits between 2023-06-17 10:55:12Z and 2023-06-18 10:55:12Z. The maximum response size detected 20124128 is greater than 204800. Redis server is designed as a highly performant store for lightweight pieces of data, generally smaller than 200KB. Requests that produce larger responses often cause problems because the Redis server and client libraries are optimized for rapidly processing and transmitting many small requests. Attempting to move large payloads through this system can severely impact Redis server load and performance, leading to command timeouts and failures in the client application.

What can cause large response sizes?

    Sending requests to the server that result in responses larger than 200KB. For example, the KEYS command can return all the keys in the cache, which could be a large volume of data.
    Storing individual values in the cache larger than 200KB.

Recommendations

    Avoid storing large values in the cache: Split large values into multiple smaller values, and send them to the cache individually.
    Consider using another type of data store designed for large values: Databases, storage accounts, or a content delivery network might be more suitable for your applications needs.
rwagner00 commented 1 year ago

Unfortunately I'm not sure that this is a bug in the WP Redis module so much as a conflict between something that WP wishes to store/retrieve in Redis and a setting in the Azure Redis instance. The log doesn't specifically call out which units of measurement it's using, but if the size 20124128 is in bytes as I suspect, that's a 20MB entry in the Redis cache. This would be very abnormally large for a cache entry, and is probably a file of some sort which should be served via the filesystem or a CDN.

With that in mind, my first recommendation would be to investigate what Redis is attempt to store that is that large, and determining:

  1. What, specifically, the site is attempting to cache
  2. Whether it is WP Core, custom code, or a third party plugin attempting to cache this item
  3. Whether or not It is appropriate to cache this item at all

If it turns out to be a misreporting or a bug, please let us know!

elmeligy commented 12 months ago

Hi J Ryan

thank you for your feedback

is there a way you recommend to check what WP is trying to store on redis ? is there an option in the plugin like debug log , that can show what it is trying to store ?

also , is there a way to set the max response size ?