Memcached & performance tuning

The Drupal Operator can optionally deploy Memcached alongside Drupal and lets you tune resource requests/limits for Drupal, MariaDB, and Memcached.

Enabling Memcached

Memcached is enabled via a boolean memcached flag in the Drupal spec. When memcached: true, the operator will create:

  • A StatefulSet named <name>-memcached
  • A ClusterIP Service named <name>-memcached

Example:

apiVersion: ozzi.io/v1alpha2
kind: Drupal
metadata:
  name: example-drupal
  namespace: drupal-demo
spec:
  drupal_image: drupal:11.2.8-php8.4-apache
  drupal_replicas: 1

  memcached: true

Defaults from roles/setup/vars/main.yaml:

  • memcached_image: memcached:1.6.10-alpine
  • memcached_container_port: 11211

The operator also sets resource requests and limits (see below).

Using Memcached from Drupal

Once Memcached is deployed, you can configure Drupal to use it as a cache backend via:

  • Additional settings in settings.php, or
  • Modules like memcache / redis (if you adapt configuration)

The Memcached service name will be:

  • <name>-memcached (for example example-drupal-memcached)

so in your configuration you can point Drupal to:

  • Host: example-drupal-memcached
  • Port: 11211

Resource tuning

The operator exposes several defaults for resource management. You can override these in your Drupal CR (if your templates pass them through) or by modifying roles/setup/vars/main.yaml / overlays.

Drupal resources

  • drupal_resources_requests_memory: 128Mi
  • drupal_resources_requests_cpu: 90m
  • drupal_resources_limits_memory: 1024Mi
  • drupal_resources_limits_cpu: 1000m

These values are applied to the Drupal Deployment’s container resources.

MariaDB resources

  • db_resources_requests_memory: 200Mi
  • db_resources_requests_cpu: 100m
  • db_resources_limits_memory: 1024Mi
  • db_resources_limits_cpu: 1000m

These values are used for the MariaDB StatefulSet.

Memcached resources

  • memcached_resources_requests_memory: 70Mi
  • memcached_resources_requests_cpu: 10m
  • memcached_resources_limits_memory: 512Mi
  • memcached_resources_limits_cpu: 250m

These limits help ensure Memcached has enough RAM to be useful without starving other workloads.

Probes and readiness

The operator configures liveness/readiness probes for Drupal and Memcached. For Drupal:

  • drupal_readinessProbe_initialDelaySeconds: 5
  • drupal_readinessProbe_periodSeconds: 5
  • drupal_readinessProbe_timeoutSeconds: 120
  • drupal_livenessProbe_tcpSocket_port: 80
  • drupal_livenessProbe_initialDelaySeconds: 10
  • drupal_livenessProbe_periodSeconds: 10
  • drupal_livenessProbe_timeoutSeconds: 3
  • drupal_liveness_probe: true
  • drupal_custom_liveness_probe: ""
  • drupal_custom_readiness_probe: ""

You can:

  • Rely on these defaults, or
  • Provide custom probe definitions (for example, HTTP checks) via drupal_custom_liveness_probe and drupal_custom_readiness_probe.

Memcached uses simple TCP socket probes on its service port.

Practical tuning tips

  • Increase Drupal memory limits for heavy sites, many contrib modules, or large imports. Adjust drupal_resources_limits_memory and PHP limits (drupal_php_memory_limit).

  • Increase DB resources if you see slow queries or frequent restarts of the MariaDB pod; consider raising db_resources_requests_memory and db_resources_limits_memory.

  • Adjust Memcached resources to keep it from evicting keys too often.

  • Use Memcached for caching heavy pages/views or large configuration sets to reduce DB load and improve response times.

For PHP- and web-server–specific tuning (PHP-FPM, Nginx, upload sizes), see PHP & web server tuning.