Many thanks for sharing your insights + setups @strarsis & @Simeon, much appreciated…!
I went ahead and got Redis to work, a few thoughts / additions regarding the setup:
The forked Ansible role https://github.com/im-mortal/trellis-redis
was a great starting point for me but there were a few things I needed to add / tweak so I forked that one as https://github.com/E-VANCE/trellis-redis.
- The version-specific PHP package is missing, thus I couldn’t get Redis to work. Added this to
/tasks/main.yml
- name: Install php-redis (version specific)
apt:
pkg: php7.4-redis
state: present
update_cache: true
notify: Restart php-fpm
NOTE: Could / should use a version-placeholder for upwards compatibility…
- The default Redis-config only assigned 128mb as
redis_maxmemory
(which might be sensible, not sure as of now) but also setredis_maxmemory_policy
to noeviction which makes Redis return a write error once the memory limit has been reached… Thus:
# Max memory values
redis_maxmemory: 2gb
redis_maxmemory_policy: volatile-ttl
redis_maxmemory_samples: 5
NOTE: See this great article regarding the memory aspects as well as the ansible-redis readme which has extensive explanations on the config variables / parameters
- Setting the
WP_REDIS_DEFAULT_EXPIRE_SECONDS
constant via Bedrock’sconfig/application.php
allows for a sensible key expiration, see #263 in WP Redis - Monitor the memory usage and check for plugins that put a great load on Redis, those can be excluded via the designated
wp_cache_add_non_persistent_groups
-function in WP Redis