Performance March 2, 2026 11 min read

Install Redis on Ubuntu VPS (2026): Fast Caching for Node.js and WordPress

Redis can dramatically reduce response times and database load. This guide covers installation, production-safe configuration, persistence, and common tuning options.

Why Redis on a VPS?

Redis is an in-memory data store used for caching, sessions, queues, and rate limiting. For busy apps, it removes repeated database work and improves page speed significantly.

Step 1: Install Redis

sudo apt update
sudo apt install redis-server -y
sudo systemctl enable redis-server
sudo systemctl start redis-server
redis-cli ping

If setup is correct, redis-cli ping returns PONG.

Step 2: Basic Security Hardening

Edit Redis configuration:

sudo nano /etc/redis/redis.conf

bind 127.0.0.1 ::1
protected-mode yes
port 6379
# optional auth:
# requirepass YOUR_STRONG_PASSWORD

Restart Redis after edits:

sudo systemctl restart redis-server
sudo systemctl status redis-server

Step 3: Memory and Persistence Settings

# in /etc/redis/redis.conf
maxmemory 256mb
maxmemory-policy allkeys-lru
appendonly yes

allkeys-lru is a strong default for cache-heavy workloads. Enable appendonly if you need better persistence guarantees.

Step 4: UFW Rules

Keep Redis private. Usually you should not expose port 6379 publicly.

# usually no public allow rule for 6379
sudo ufw status

# if previously exposed by mistake:
sudo ufw deny 6379/tcp

Integrating Redis Quickly

FAQ

Should Redis run on the same VPS as my app?

For small to medium projects, yes. For larger workloads, separate Redis to isolate memory pressure.

Do I need a Redis password if bound to localhost?

Local binding is a strong baseline. Password is still recommended for defense in depth.

How do I verify memory usage?

Use redis-cli INFO memory and monitor used_memory_human, eviction stats, and fragmentation ratio.

Continue with VPS performance monitoring and swap optimization for stable performance under load.