Magento

Redis Caching in Magento 2: Full-Page Cache and Session Storage

9 min read·246 words
Redis Caching in Magento 2: Full-Page Cache and Session Storage

A deep dive into Redis configuration for Magento — covering full-page cache, session storage, and the exact settings we use to achieve sub-100ms TTFB on enterprise installs.

Redis is the backbone of a high-performance Magento setup. It replaces file-based storage for the default cache, the full-page cache, and session storage — taking all three from disk I/O-bound to sub-millisecond memory operations. Here's the production-ready configuration we use.

Three Redis Instances, Three Jobs

Never use a single Redis instance for everything. Run three separate instances: one for the default cache (volatile data, no persistence needed), one for the full-page cache (large values, LRU eviction), and one for sessions (must persist across Redis restarts to avoid logging out customers). Different eviction policies and memory limits for each.

Tuning maxmemory and Eviction Policy

  • Default cache: maxmemory 2gb, maxmemory-policy allkeys-lru
  • Full-page cache: maxmemory 8gb, maxmemory-policy allkeys-lru
  • Sessions: maxmemory 4gb, maxmemory-policy noeviction (never evict sessions), enable persistence
  • Set maxmemory-samples 10 for better LRU approximation accuracy
  • Disable transparent huge pages (THP) at the OS level — major Redis performance killer

Redis Cluster for High Availability

For enterprise setups, run Redis Sentinel or Redis Cluster. Sentinel provides automatic failover with a primary-replica setup. Cluster provides horizontal scaling across multiple nodes. Magento's cm_cache_backend_redis library supports Sentinel natively — configure sentinels array in env.php to point to your Sentinel instances.

Monitoring Redis Health

Monitor hit ratio (should be >95%), evicted_keys (should be 0 for sessions), connected_clients, and used_memory vs. maxmemory. A dropping hit ratio means your cache is too small or TTLs are too short. Alert on memory usage above 85% to give you time to expand before evictions start impacting performance.

#magento#ecommerce#adobe-commerce#magento-2#magento-development#caching#full-page