What Magento keeps in Redis
A typical setup uses three separate Redis databases, written by setup:config:set into env.php:
| Data | Database | If it is lost |
|---|---|---|
| Default cache (config, layout, blocks) | 0 | Slower pages while it rebuilds |
| Full page cache | 1 | Slower pages while it rebuilds |
| Customer sessions | 2 | Logged out, cart and checkout step lost |
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-db=0
bin/magento setup:config:set --page-cache=redis --page-cache-redis-db=1
bin/magento setup:config:set --session-save=redis --session-save-redis-db=2Why a full Redis empties carts
When Redis reaches its maxmemory, it applies the eviction policy. With a policy such as allkeys-lru it deletes the least recently used keys, and it does not care which database they live in. A busy catalog fills the cache, Redis makes room, and the sessions of shoppers who paused for a few minutes are gone.
maxmemory and maxmemory-policy belong to the Redis instance, not to a database number. Database 2 is not protected because cache lives in 0 and 1.
With noeviction the opposite happens: Redis refuses writes when it is full, and the store starts throwing errors instead of losing sessions quietly. Neither is acceptable for checkout, which is why sessions belong in their own instance.
Check memory and evictions
Ask the instance that holds the sessions how full it is and whether it has been evicting keys:
redis-cli -p 6379 info memory | grep -E "used_memory_human|maxmemory_human|maxmemory_policy"
redis-cli -p 6379 info stats | grep -E "evicted_keys|rejected_connections"
redis-cli -p 6379 info keyspaceevicted_keys above 0 on the session instance means sessions have been deleted to make room.A safe setup
- Two instances. One for cache and full page cache with
allkeys-lru; one for sessions withnoevictionand enough memory for peak traffic. - Size the session instance. Sessions are small, but sale days multiply them; leave clear headroom.
- Point sessions to it. Set the session host and port in env.php, for example with
--session-save-redis-port=6380. - Alert on memory. Warn before the session instance reaches its limit, not after.
# Session instance (6380): never evict, fail loudly instead
redis-cli -p 6380 config set maxmemory 1gb
redis-cli -p 6380 config set maxmemory-policy noevictionconfig set lasts until restart; put the same values in that instance’s redis.conf.bin/magento cache:flush clears the cache backends. A redis-cli flushall on a shared instance also logs every customer out.
Catch it from outside
A lost session looks like a working store: pages load, products add to the cart. A check that keeps the cart through checkout, as a real shopper does, is what shows it. Related: full page cache and checkout and checkout performance.
Check your own store now with the free Magento checkout test: it walks the checkout in a real browser and shows the step where it stops.
Find out your checkout broke before your customers do.
Real checkout checks for Magento and WooCommerce · free plan · no card requiredMagento checkout monitoring →