Redis Cache By Xon

Redis Cache By Xon 2.17.2

No permission to download
My forum crashed immediately on upgrade from 2.14.0 to 2.15.0 - any ideas?

1694440726633.png

I had to;

$config['enableListeners'] = false;

... to get the site back, to then remove 2.15.0, and I installed 2.14.0 to get it back.
 
Last edited:
My sites appear slower with reads since the 2.15.0 update. Anyone else experiencing this?
There shouldn't be any performance difference beyond 2-3 more file loads. Maybe if opcache is incorrectly configured? Try restarting php-fpm/apache.

If you have debug mode enabled (or can enable it for yourself), you can check the redis stats on ?_debug=1 to see if that is reporting anything obviously wrong.

My forum crashed immediately on upgrade from 2.14.0 to 2.15.0 - any ideas?

View attachment 290942

I had to;



... to get the site back, to then remove 2.15.0, and I installed 2.14.0 to get it back.
Without seeing the error, this is impossible to debug. You'll likely need to extract it from the webserver logs or enable XF's debug mode so XF can dump the stack trace.

If you deleted the old files, and then uploaded new ones; do not do that. That is absolutely not supported.
(It shouldn't make a difference in this case, but I'm not doing to support that upgrade process)
 
Without seeing the error, this is impossible to debug. You'll likely need to extract it from the webserver logs or enable XF's debug mode so XF can dump the stack trace.

If you deleted the old files, and then uploaded new ones; do not do that. That is absolutely not supported.
(It shouldn't make a difference in this case, but I'm not doing to support that upgrade process)

? I didn't - I upgraded as you'd expect/normal - as I have for many years with this add-on.

The last upgrade, immediately crashed the forum.

3,000+ server error logs - mainly;

1694442876175.png

1694442857759.png

After the crash, I rolled back and 2.14.0 works as it always did.

My XF is v2.2.13
 
Last edited:
? I didn't - I upgraded as you'd expect/normal - as I have for many years with this add-on.

The last upgrade, immediately crashed the forum.

3,000+ server error logs - mainly;

View attachment 290944
Will be fixed in the next version, which will be out after some more testing. The fix till then is to remove the $config['cache']['config]['redis'] key, or stay on v2.14.x

This is unrelated to my add-on, but could be an artifact of the caching layer being broken when templating was invoked.
 
To clear the Redis database, you have two main options:
  1. FLUSHDB: This command clears the current Redis database.
  2. FLUSHALL: This command clears all databases in the Redis instance.
 
The HA support currently requires the use of redis sentinel to find replicas. You can adjust the replica config so the sentinel never promotes them, but it is still required by the add-on.
 
The HA support currently requires the use of redis sentinel to find replicas. You can adjust the replica config so the sentinel never promotes them, but it is still required by the add-on.
I see

I’m running a very large forum that has 1 master server and 2 slaves.

The master server contains:
  • 1 redis-server
  • 1 database server
  • all the php files
The slave servers each contain:
  • 1 redis-server in replica mode
  • php-fpm
  • The slave servers mount the php files from the master server (with cachefs)

A nginx load balancer on top of the entire setup orchestrates traffic between the slaves.

While both master and slave servers are fairly powerful (128 GB RAM / NVMe drives), I’m having an issue that the master server saturates the 1Gbit LAN link and causes a lot of problems during peak periods. I’m figuring out how to load balance mysql (master -> replica), but in the meantime, I’m trying to set up redis-sentinel. Performance is what I’m looking for, but since your plugin can load redis database from local replica, I’m trying this route first.


Can you look at my config to see if the slaves will prefer to load from local replica server properly? (To avoid saturation of the limited link of the master)

PHP:
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
    'sentinel_master' => 'mymaster',
    'server' => 'tcp://10.0.10.10:26379,tcp://10.0.10.15:26379,tcp://10.0.10.20:26379',
    'load_from_replicas' => 2,
    'replica_select_callable' => 'preferLocalReplicaLocalDisk',
    'retry_reads_on_primary' => true,
    'compression_lib' => 'zstd',
    'use_lua' => true,
    'read_timeout' => 1,
    'timeout' => 1,
    'serializer' => 'igbinary',
    'compress_data' => 6,
];

Bash:
~ sysctl -a | grep 'max_syn\|somaxcon'

net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535

~ cat /etc/redis/redis.conf | grep tcp-backlog
tcp-backlog 65536

From redis-cli INFO CLIENT, I can see some connected clients on all replicas, but I’m having a lot of read errors on the redis master IP address in the log.

If I get rid of the redis-sentinel (since I don't need HA), would this config work instead:


PHP:
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
        'server' => '10.0.10.10',
        'port' => 6379,
        'compression_lib' => 'zstd',
        'use_lua' => true,
        'read_timeout' => 1,
        'timeout' => 1,
        'serializer' => 'igbinary',
        'compress_data' => 6,
];

$config['cache']['config']['load_from_slave'] = array(
        'server' => '10.0.10.15',
        'port' => 6379,
        'compression_lib' => 'zstd',
        'use_lua' => true,
        'read_timeout' => 1,
        'timeout' => 1,
        'serializer' => 'igbinary',
        'compress_data' => 6,
);

Also from your FAQ, load_from_slave is used with single replica but load_from_replica is what being discussed in this forum, should it be load_from_replica for single redis slave?
And note that in your FAQ, the single replica end with array ends with ]; I think it's wrong and it should have been );

1697829662517.png
 
Last edited:
I've updated the FAQ with the correct terminology; load_from_replica, since redis has moved away from master/slave to primary/replica terminology.

It has actually been a while since I've looked at the replica support. It looks like you can make load_from_replica and array, but it will pick a random replica and ignore the replica_select_callable option.

From redis-cli INFO CLIENT, I can see some connected clients on all replicas, but I’m having a lot of read errors on the redis master IP address in the log.
Make sure to disable all the redis persistence options. XF will regenerate any missing cache items, the cache simply does not need to be persistent.

Can you look at my config to see if the slaves will prefer to load from local replica server properly? (To avoid saturation of the limited link of the master)

PHP:
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
    'sentinel_master' => 'mymaster',
    'server' => 'tcp://10.0.10.10:26379,tcp://10.0.10.15:26379,tcp://10.0.10.20:26379',
    'load_from_replicas' => 2,
    'replica_select_callable' => 'preferLocalReplicaLocalDisk',
    'retry_reads_on_primary' => true,
    'compression_lib' => 'zstd',
    'use_lua' => true,
    'read_timeout' => 1,
    'timeout' => 1,
    'serializer' => 'igbinary',
    'compress_data' => 6,
];
This should work.

Another thing is to run multiple redis instances to shard the load across many threads;

PHP:
$config['cache']['enable'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [...];
$config['cache']['context']['sessions'] = ['provider' => 'SV\RedisCache\Redis', 'config' => [ ... ]];
$config['cache']['context']['css'] = ['provider' => 'SV\RedisCache\Redis', 'config' => [ ... ]];

I’m running a very large forum that has 1 master server and 2 slaves.
Spacebattles is currently doing ~130mbits of bandwidth usage against the redis cluster. Practically all of that is hitting the local redis instance instead of crossing the network, and it is almost entirely compressed data as well.

I do performance consulting for XF's software stack and also sysadmin work, so if you want more in-depth paid help open a ticket on my site.
 
Last edited:
Xon updated Redis Cache By Xon with a new update entry:

2.15.4 - Bugfix update

  • Fix helper code to expire/purge redis keys did not support non-main cache backends.
    • If using a separate caching backend for css, old styling was not actively expired as expected, resulting in higher memory usage
    • If 3rd party code uses expireCacheByPattern/purgeCacheByPattern function, the new nullable 'cache' parameter should be used

Read the rest of this update entry...
 
I've been getting these lately
Code:
[14-Dec-2023 06:09:31 UTC] PHP Fatal error:  Uncaught CredisException: LOADING Redis is loading the dataset in memory in /.../.../public_html/src/addons/SV/RedisCache/Credis/Client.php:1517
Stack trace:
#0 /.../.../public_html/src/addons/SV/RedisCache/Credis/Client.php(1244): Credis_Client->read_reply('mget')
#1 /.../.../public_html/src/addons/SV/RedisCache/DoctrineCache/Redis.php(125): Credis_Client->__call('mget', Array)
#2 /.../.../public_html/src/addons/SV/RedisCache/Traits/CacheTiming.php(41): SV\RedisCache\DoctrineCache\Redis->SV\RedisCache\DoctrineCache\{closure}()
#3 /.../.../public_html/src/addons/SV/RedisCache/DoctrineCache/Redis.php(156): SV\RedisCache\DoctrineCache\Redis->redisQueryForStat('gets', Object(Closure))
#4 /.../.../public_html/src/addons/SV/RedisCache/DoctrineCache/CacheProvider.php(63): SV\RedisCache\DoctrineCache\Redis->doFetchMultiple(Array)
#5 /.../.../public_html/src/XF/DataRegistry.php(115): SV\RedisCache\DoctrineCache\CacheProvider->fetchMultiple(Array)
#6 /.../.../public_html in /.../.../public_html/src/addons/SV/RedisCache/Credis/Client.php on line 1517
 
Top Bottom