Configure your sessions in Redis for Magento 2
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:
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