Redis significantly improves e-commerce platform performance by caching database query results and, for platforms that support it, session data — reducing load on MySQL/MariaDB for repeated, expensive operations.
Why E-commerce Platforms Benefit Especially from Redis
E-commerce platforms perform many repeated, often complex database queries (product listings, pricing rules, inventory checks) — caching these results in Redis avoids re-running expensive queries on every page load.
Prerequisites
- Redis installed (see How to Install and Secure Redis on Ubuntu & Debian)
- WooCommerce or Magento already installed
Configuring Redis for WooCommerce (via WordPress)
Install a Redis object cache plugin for WordPress (several well-maintained options exist):
wp plugin install redis-cache --activate
wp redis enable
Verify it's working under Settings → Redis in the WordPress admin, which should show "Connected" status.
Configuring Redis for Magento (Cache Backend)
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0
Configuring Redis for Magento (Session Storage)
bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-db=2
Using separate Redis database numbers for cache and sessions keeps them logically separated within the same Redis instance.
Verifying Magento's Redis Configuration
cat app/etc/env.php | grep -A 5 redis
Restarting Services After Configuration Changes
bin/magento cache:flush
sudo systemctl restart php8.2-fpm
Monitoring Redis Performance
redis-cli info stats
Check keyspace_hits vs keyspace_misses — a high hit ratio indicates the cache is working effectively; a low ratio suggests cache configuration or expiration settings may need adjustment.
Setting Appropriate Memory Limits
sudo nano /etc/redis/redis.conf
maxmemory 1gb
maxmemory-policy allkeys-lru
allkeys-lru automatically evicts least-recently-used keys once memory limit is reached, appropriate for a pure caching use case.
Separating Redis Instances for Cache vs Sessions (Higher-Traffic Sites)
For larger stores, consider running separate Redis instances (or at least separate persistence settings) for cache (safe to lose, purely performance) vs sessions (losing this logs out all active users) — different tolerance for data loss justifies different configuration.
Common Errors
"Could not connect to Redis" — verify Redis is running (sudo systemctl status redis-server) and that the host/port in your platform's configuration matches Redis's actual listening address.
No apparent performance improvement — verify the cache is actually being hit (check hit ratio above); a misconfiguration might result in Redis running but not actually being used by the application.
Continue Reading
- How to Install and Secure Redis on Ubuntu & Debian
- How to Optimize a VPS for High-Traffic E-commerce
- How to Tune MySQL/MariaDB Performance for a VPS
Browse more articles in E-commerce Platform Deployment.