Magento is a feature-rich eCommerce platform that provides control and peerless flexibility over the content and functionality of an online store. It is built on impressive feature set, thus providing a standardized and functional architecture and extended PHP Technology features. Sessions are user-specific data that is stored on the server for each client and the server maps clients to their sessions with a cookie. When you go back to a Magento store after a few days of browsing it, and you find that the items you added to cart are still in the cart – that is known as sessions. How quickly data can be put in and got out of the session storage, how it is distributed in a clustered environment and how volatile it is are some of the important considerations when choosing how to store sessions. There are four methods for magento session storage. So let us see which is the best Magento session storage to use.
File system Session storage
Simplicity, durability and stability are the benefits of file-based sessions for Magento. It’s simple because you don’t have to do anything to set it up and most modern file systems use journaling to make sure that your session data is consistent in the event of a system crash which shows its stability. It’s also durable, because restarting your system will not cause you to lose your session data. To enable file-based storage, choose it in your app/etc/local.xml file or during installation.
Database Session storage
Database session storage is the other storage type, where the session data is stored in the Magento MySQL database. The clustered environment support is one of the key benefits of using database sessions. If you have more than one Magento frontend node in a cluster, in a file system based session storage scheme, they will need to share session data unless you use a load balancer with sticky sessions but the database gives you that capability quite easily. Databases also have good durability and stability during reboots and crashes. One of the problems with database session storage is that it adds more load to the database.
Memcached Session storage
Memcached session storage takes a bit more setup than other options, which is why it’s not considered a normal option during Magento install. But the memcached session storage offers a number of benefits once you have it up and running. It is very cluster friendly and the session data can be shared by any number of web nodes. It is fast as the memcached keeps all its data in memory. However, if your system crashes or dies the data in memory will be lost as the memcached server is not tolerant to failures.
Tmpfs-backed File system Session storage
This is not a good idea for storing sessions as it’s highly volatile and unstable. It’s also not scalable as it relies on the machine’s physical memory. As it is machine specific, it will also not help at all in a clustered environment.
Here we have looked at the benefits and limitations of each Magento session storage option, and it is quite surprising at how little each option affected the store’s performance. This shows that session storage is not so much about performance as it is about suitability and stability for your requirements.