9

I have to choose Session Save - 'Files' or 'DB' while installing Magento2

What is different, advantage, disadvantage?

What should I choose?

4 Answers 4

11

This is explained pretty nice in the Magento Devdocs (actually the functionality is the same as in Magento 1):

In the Session Storage Options section, click one of the following options:

File to store user session data on the file system in the [your Magento install dir]/var/session directory. File-based session storage is appropriate unless the Magento file system access is slow or you have a clustered database.

Database to store user session data in the database. Choose database storage if you have a clustered database; otherwise, there might not be much benefit over file-based storage.

See here: http://devdocs.magento.com/guides/m1x/install/installing_install.html

2
  • 1
    I wanted to add we've tested and seen a degradation of performance of using database in non-clustered environment on many lower end hosting environments so would recommend using file system for those cases.
    – Eirik
    Dec 14, 2015 at 19:32
  • 1
    NB Mag2 sessions are not stored in de app tree but under the default PHP session.save_path (usually /var/lib/php5/sessions).
    – Willem
    Feb 3, 2016 at 15:31
4

DB

session storage in database is better for security but add additional load to database.

Files

session storage that uses file system allow easy access to session information via ftp.

4

In my opinion MySQL is not really a good solution for storing the session data in it since it can slow down your database also it can grow huge.

Either way: Don't forget to set up the cleaning for the sessions because they can take up quite a big space after a while.

0

We should use Redis for our site.

1) Reduce stress to the website database.

2) https://redis.io/topics/introduction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.