Drupal is amazing but its admin experience can be a bit sluggish if you don’t have a proper cache backend configured.
After reorienting myself I though of writing a guide / checklist for modern drupal / kubernetes integration in a modern drupal9 , cloud-native (k8s based) enviornment
Each Drupal page load , loads hundreds of MySQL queries but many of them are the same exact queries across page loads. This is where drupal caching comes extremely handy .
There is a great blog post in the pantheon web site that covers how awesome Drupal caching is with redis the image below (taken from there) shows how db query overhead goes to practically nothing after you enable redis
So the first thing to prepare is to ensure you have a Redis deployment in your k8s namespace .
This can easily be done by installing it with helm – there is a useful blog post here
Make sure you get the internal hostname for redis (typically the endpoint value in the redis service)
Second, we need to make sure that our docker image has Redis preinstalled – we love using the wodby images for this (and much much more).
The best way to verify this is to review your phpinfo information (Easily viewed by going to yourdrupal.com/admin/reports/status/php and finding the Redis section in the PHP info presented.
The redis module is in charge of helping you connect and validate that your Redis connection is working well.
You can download it from drupal.org by ging to its homepage here , but the modern and recommended best practice is to add it to your compose.json file by running
composer require drupal/redis
After we’ve made sure that we’ve prepared everything we now want to “tell Drupal” to cache in redis.
We do this by adding the rellevent lines in to you settings.php – a good practice will be to load it to setting.local.php to store your customizations.
$settings['redis.connection']['interface'] = 'PhpRedis'; $settings['redis.connection']['host'] = 'redis'; $settings['cache']['default'] = 'cache.backend.redis';
The first part is simply to make sure you’ve enabled caching by login in to the admin and going config >> development >> performance and simply enabling the Drupal cache.
The redis module provides a really cool way to understand the status of redis , the keys used and the configurations.
You can check that out by going to admin >> reports >> redis