Configure your sessions in Redis for Magento 2

in ToolsUsage

Hypernodes bigger than a Grow plan, often have enough memory to store the session data in Redis.
This way sessions are stored in-memory, making the shop faster and use less IO than when using MySQL or files as session store.

Configure Magento 2 to store sessions in Redis

As Magento 2 is fully supporting Redis, there is no need to install additional extensions to configure Redis.
All you need to do is extend your app/etc/env.php and flush your cache.

To enable session storage in Redis, extend your /data/web/magento2/app/etc/env.php with the following snippet:

A complete env.php configuration example can be found over here

Now flush your cache:

rm -rf /data/web/magento2/var/cache/*
redis-cli flushall

Test whether your sessions are actually stored in Redis

To verify whether your configuration is working properly, first clear your session store:

rm /data/web/magento2/var/sessions/*

Now open the site in your browser and hit F5 a few times or log in to the admin panel.
If all is well, no additional sessions files should be written to /data/web/magento2/var/session, but instead to the Redis database:

redis-cli -n 2 keys \*


For troubleshooting and an extended howto, please check the manual on the Magento website