A multisite WordPress network with 60 subsites runs a single-instance Redis for object cache. It works well for two years. Then traffic doubles, the editorial team adds a heavy wp_query on the home page that fragments cache keys per subsite, and the Redis box’s used_memory climbs past 14 GB. You add memory once, twice, then a maintenance reboot takes the cache offline for ninety seconds — and during those ninety seconds every backend page request hits MySQL directly, the database goes to 100% CPU, and the front end serves 502s. Single-instance Redis is the right answer for a small-to-medium WordPress install. For multisite at scale, the question is which distributed pattern, not whether to distribute.
What’s happening
WordPress’s object cache is a key-value store keyed on cache_group:cache_key. By default it lives in PHP memory and dies at the end of the request. A persistent object cache backend (Redis, Memcached, Memcache) replaces the in-memory implementation with one that survives across requests. WordPress core ships the API; the drop-in (wp-content/object-cache.php) ships the backend.
For Redis specifically, three deployment shapes show up in production:
-
Single-instance Redis with AOF persistence. One server, simple, fine up to roughly 16 GB of working set and the throughput a single Redis process can handle (~100k ops/sec for typical WP key sizes). Failure mode: any reboot or network blip flushes the cache, MySQL gets the full load.
-
Redis Sentinel (1 primary + N replicas + 3 sentinels). Replicated, with automatic failover. The client (phpredis or relay) sees a single logical Redis through the sentinel discovery API. Failover takes 5-30 seconds depending on
down-after-millisecondsconfig. Capacity ceiling is still one node’s worth of RAM. -
Redis Cluster (3+ shards, each with 1 primary + 1-2 replicas). Native sharding — keys are hashed to one of 16384 slots, slots distribute across primaries. Linear capacity scaling. Failover is per-shard. The catch: clients must be Cluster-aware, multi-key operations (MGET across slots, MULTI/EXEC) must hash-tag related keys to the same slot, and the
object-cache.phpdrop-in must support Cluster mode.
For multisite WordPress, the per-subsite cache key namespace is critical. By default WP_Object_Cache prefixes keys with the blog ID (2:options:alloptions, 42:posts:post-1234). If the drop-in flattens this into Redis without preserving the blog ID, two subsites can collide. If the drop-in over-prefixes (e.g., adds the network ID + blog ID + site URL), the key space explodes and eviction churn becomes the bottleneck instead of capacity.
Eviction policy matters for distributed object cache more than people assume. allkeys-lru is the default for object cache — when memory fills, the least-recently-used key is evicted. But WordPress has a class of keys that are cheap to recompute (transient cache for a single post’s meta query) and a class that is expensive (the alloptions blob, which is read on every request). volatile-lru plus explicit TTLs on cheap keys and no TTL on expensive ones is the pattern that holds.
How to verify
Inspect the current object cache state from a running WordPress install:
# is an object cache drop-in installed?
wp eval 'var_dump(wp_using_ext_object_cache());'
# what backend?
wp eval 'global $wp_object_cache; echo get_class($wp_object_cache) . "\n";'
# Redis-specific stats (if Object Cache Pro or similar drop-in)
wp redis info # if the drop-in exposes it, otherwise:
wp eval 'global $wp_object_cache; print_r($wp_object_cache->info());'
Directly inspect Redis to characterize key shape and eviction:
redis-cli -h $REDIS_HOST INFO memory | grep -E "used_memory_human|maxmemory_policy|evicted_keys"
redis-cli -h $REDIS_HOST INFO stats | grep -E "keyspace_hits|keyspace_misses|expired_keys"
# sample 100 keys to see the namespace shape
redis-cli -h $REDIS_HOST --scan --count 100 | head -100
If keyspace_hits / (keyspace_hits + keyspace_misses) is below 0.95, the cache is not warming properly — either TTLs are too short, eviction is too aggressive, or the cache is being flushed by an over-eager invalidation hook in a plugin.
To confirm the per-subsite namespace is intact on multisite:
redis-cli -h $REDIS_HOST --scan --pattern "*:options:alloptions" --count 200 | head -20
# expected: one key per active subsite, prefixed with blog ID
For Cluster, verify topology and slot distribution:
redis-cli -c -h $REDIS_HOST CLUSTER NODES
redis-cli -c -h $REDIS_HOST CLUSTER INFO
redis-cli -c -h $REDIS_HOST CLUSTER COUNTKEYSINSLOT 0 # spot check slot distribution
The fix
The decision is sized by working set and failure tolerance:
- Working set < 8 GB, single-site or small multisite, can tolerate ~60s cache cold-start after a reboot → single instance with AOF + a warmer cron job.
- Working set 8-30 GB or zero-downtime SLO on the object cache layer → Sentinel with 3 sentinels + 1 primary + 2 replicas.
- Working set > 30 GB or multisite network with 100+ subsites → Cluster with 3+ shards.
Below is the deployment for the Cluster case on AlmaLinux 9, which is the path most multisite networks end up needing.
#!/usr/bin/env bash
# Redis Cluster for WordPress multisite object cache
# 3 primaries + 3 replicas, 6 nodes total
# Run on each node, then bootstrap the cluster from one of them.
set -euo pipefail
NODE_IP="${NODE_IP:?set NODE_IP to this node's private IP}"
CLUSTER_PORT=6379
BUS_PORT=16379
dnf -y install redis
# per-node config
cat > /etc/redis/redis.conf <<EOF
bind ${NODE_IP}
port ${CLUSTER_PORT}
protected-mode yes
appendonly yes
appendfsync everysec
maxmemory 24gb
maxmemory-policy allkeys-lru
cluster-enabled yes
cluster-config-file /var/lib/redis/nodes-${CLUSTER_PORT}.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
cluster-replica-validity-factor 10
cluster-allow-reads-when-down no
tls-port 0
tcp-keepalive 60
timeout 0
# slow log threshold tuned for WP workload — anything over 10ms is interesting
slowlog-log-slower-than 10000
slowlog-max-len 256
# notify-keyspace-events kept empty unless you genuinely subscribe to expirations
notify-keyspace-events ""
EOF
# firewall — only allow cluster traffic between cluster nodes
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="6379" protocol="tcp" accept'
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="16379" protocol="tcp" accept'
firewall-cmd --reload
systemctl enable --now redis
# bootstrap from one node only — adjust IPs
# redis-cli --cluster create \
# 10.0.0.11:6379 10.0.0.12:6379 10.0.0.13:6379 \
# 10.0.0.14:6379 10.0.0.15:6379 10.0.0.16:6379 \
# --cluster-replicas 1 --cluster-yes
On the WordPress side, use a Cluster-aware drop-in. Object Cache Pro supports Cluster mode natively; the Redis Object Cache plugin needs explicit Cluster config:
// wp-config.php — Cluster mode
define('WP_REDIS_CLUSTER', [
'tcp://10.0.0.11:6379',
'tcp://10.0.0.12:6379',
'tcp://10.0.0.13:6379',
]);
// hash tag the network-wide keys to keep them on one slot for MGET efficiency
define('WP_CACHE_KEY_SALT', 'prod-net1');
define('WP_REDIS_PREFIX', '{prod-net1}:');
// multisite — preserve per-blog namespace
define('WP_REDIS_SELECTIVE_FLUSH', true);
define('WP_REDIS_MAXTTL', 3600);
// fall back to no-cache instead of fataling on connection loss
define('WP_REDIS_GRACEFUL', true);
The {prod-net1} hash tag tells Redis to hash only the bracketed portion when computing the slot — every key in the cluster lands on the same shard. This works at small to mid scale but defeats the purpose of Cluster past a certain size. For a true 3+ shard distribution, drop the hash tag and let WP keys distribute naturally; the cost is that any multi-key operation (which Object Cache Pro uses for alloptions and group invalidation) needs the keys hash-tagged at the application layer.
Eviction tuning to apply once the cluster is running:
# on each primary
redis-cli -h $PRIMARY_IP CONFIG SET maxmemory-policy allkeys-lru
redis-cli -h $PRIMARY_IP CONFIG SET active-expire-effort 8 # default 1, more aggressive expiration sweep
redis-cli -h $PRIMARY_IP CONFIG REWRITE
For multisite scoping, audit the per-subsite key distribution after one week:
# count keys per subsite (assumes blog ID prefix)
redis-cli -h $PRIMARY_IP --scan --pattern "*:wp_:*" --count 1000 | \
awk -F':' '{print $2}' | sort | uniq -c | sort -rn | head
If one subsite holds 90% of the keys, the cache invalidation hooks in that subsite are misbehaving — find the plugin, fix the hook, or scope the invalidation to its own group.
The watch metric is evicted_keys_per_second — anything above 100/sec sustained means the cluster is under-sized or the eviction policy is wrong. The fix is one or both of: raise memory per shard, or move TTL-less keys to a separate group with volatile-lru.
Stack Harbor sizes, deploys, and operates the Redis tier for WordPress multisite networks under the enterprise WordPress hosting operating model — including the object-cache drop-in choice, the Cluster bootstrap, and the eviction tuning. If your single-instance Redis is past its ceiling, we can scope the cluster migration.