When a single server hosts multiple WordPress installations under RunCloud, the efficiency of the object cache becomes a critical performance factor. Redis, when fine-tuned, can dramatically reduce MariaDB load and speed up dynamic content delivery.
However, default configurations are often not tailored for environments with many sites and high traffic. This guide explains how to optimize Redis on a RunCloud + Ubuntu + LiteSpeed + MariaDB + Redis stack, especially for handling a dozen WordPress sites securely and reliably.
1. Redis as a pure object cache (no persistence)
If Redis is only used for WordPress object caching, it doesn’t need to store data on disk. When the service restarts, cache data is rebuilt automatically.
Edit /etc/redis/redis.conf
:
save ""
appendonly no
Code language: JavaScript (javascript)
This disables RDB and AOF files, reducing I/O overhead and avoiding unnecessary pauses.
2. Set memory limits and eviction policy
Never let Redis consume unlimited RAM. On a server with 12 GB of RAM, assigning around 2.5 GB to Redis is a safe baseline:
maxmemory 2560mb
maxmemory-policy allkeys-lru
maxmemory-samples 10
allkeys-lru
→ evicts the least used keys first.maxmemory-samples 10
→ improves eviction accuracy.
3. Reduce latency spikes
Redis can freeze briefly when deleting many keys at once. To offload deletions to background threads:
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
This keeps performance consistent even during heavy cache rotations.
4. Faster key expiration
For high-traffic WordPress sites, clean expired keys more efficiently:
hz 20
dynamic-hz yes
active-expire-effort 5
Increasing hz
and active-expire-effort
accelerates expiration sweeps without overloading the CPU.
5. Secure Redis with a password (requirepass
)
Even if Redis listens only on 127.0.0.1
, never leave it without authentication. In redis.conf
:
requirepass YOUR_LONG_STRONG_PASSWORD
Always use a unique password different from your WordPress or MariaDB credentials.
6. Connecting via redis-cli
with authentication
Once requirepass
is enabled, you must authenticate:
🔹 Direct authentication:
redis-cli -h 127.0.0.1 -p 6379 -a 'YOUR_LONG_STRONG_PASSWORD' ping
Code language: JavaScript (javascript)
🔹 Authenticate after connecting:
redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> AUTH YOUR_LONG_STRONG_PASSWORD
OK
127.0.0.1:6379> ping
PONG
Code language: CSS (css)
7. WordPress integration in RunCloud
For each site’s wp-config.php
, define Redis settings:
define('WP_CACHE', true);
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_PASSWORD', 'YOUR_LONG_STRONG_PASSWORD');
define('WP_REDIS_PREFIX', 'site1_'); // use a unique prefix per site
Code language: JavaScript (javascript)
If you use the LiteSpeed Cache plugin:
- Go to Object Cache → select Redis.
- Set host
127.0.0.1
, port6379
, and your password. - Assign a unique prefix for each WordPress instance.
8. Quick Redis monitoring with redis-cli
Some useful commands:
- Memory usage:
redis-cli -a 'YOUR_PASSWORD' INFO memory | egrep 'used_memory_human|maxmemory'
- Evicted keys:
redis-cli -a 'YOUR_PASSWORD' INFO stats | grep evicted_keys
- Connected clients:
redis-cli -a 'YOUR_PASSWORD' INFO clients | grep connected_clients
If evicted_keys
grows too quickly, increase maxmemory
or adjust object cache TTLs.
9. System-level optimizations
Improve Redis behavior by tuning the OS:
In /etc/sysctl.d/60-redis-tuning.conf
:
net.core.somaxconn = 1024
vm.overcommit_memory = 1
Disable Transparent Huge Pages (THP):
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
Code language: PHP (php)
Conclusion
By applying these optimizations, Redis becomes a robust object cache solution for multi-WordPress servers under RunCloud:
✅ Enforced password security (requirepass
).
✅ Controlled memory usage (~2.5 GB).
✅ Efficient LRU eviction policy.
✅ Background deletion to avoid freezes.
✅ Easy monitoring with redis-cli
.
The outcome: lighter MariaDB load, faster response times, and higher stability, even with 12 WordPress sites running in parallel.
Frequently Asked Questions (FAQ)
How much RAM should I assign to Redis in a multi-WordPress server?
Between 15 % and 25 % of total RAM is usually sufficient. On a 12 GB server, allocating 2–3 GB to Redis works well.
Is it safe to run Redis without a password if it only listens to 127.0.0.1?
Not recommended. Always use requirepass
to avoid privilege escalation or local attacks.
How do I prevent different WordPress sites from sharing the same Redis keys?
Set a unique WP_REDIS_PREFIX
in each site’s wp-config.php
. This keeps caches isolated.
Do Redis and LiteSpeed Cache do the same thing?
No. LiteSpeed Cache stores full HTML pages, while Redis accelerates database object caching. Using both yields the best performance.