Magento stores sessions by 4 means file-storage,database, memcached and tmpfs-backed file-storage
The benefits of file-based sessions for Magento are simplicity, stability and durability. It’s simple because you don’t have to do anything to set it up. It’s stable because most modern filesystems use journaling to make sure that in the event of a system crash your session data is consistent. I also durable, because a system restart will not cause you to lose your session data.
The benefits of file-based sessions for Magento are simplicity, stability and durability. It’s simple because you don’t have to do anything to set it up. It’s stable because most modern filesystems use journaling to make sure that in the event of a system crash your session data is consistent. I also durable, because a system restart will not cause you to lose your session data.
Add below line in local.xml to start file based storage
<
session_save
>
session_save
>
Database session storage is the other storage type.With database session storage the
session data is stored in the Magento MySQL database. The connection
used is the same as the core connection.
One of the key benefits of using database sessions is the clustered
environment support. In a filesystem based session storage scheme, if
you have more than one Magento frontend node in a cluster, they will
need to share session data (unless you use a loadbalancer with sticky
sessions) and the database gives you that capability quite easily.
To use the database for session storage simply have this in your local.xml
<
session_save
>
session_save
>
Memcached session storage
takes a bit more setup than either of the previous two options.For starters you need a Memcached server running.
Once you have it up and running, the memcached session storage offers
a number of benefits. Firstly it is very cluster friendly. The session
data can be shared by any number of webnodes, and to make things even
better you can easily add more memcached server nodes so that even your
session storage can be scaled to handle many 1000′s of concurrent
sessions*. Secondly, it is (or can be) separate of the database and web
node entirely, which offloads the work of storing sessions from busy
nodes in a high-traffic environment.
The memcached server is not tolerant to failures, if your system
crashes or dies the data in memory will be lost. Being a separate server
does allow the session storage to be kept running during a web or
database node restart though – something you cannot do with the tmpfs
storage option below.
To use the database for Memcached storage simply have this in your local.xml
<
session_save
>
session_save
>
<
session_save_path
>
session_save_path
>
tmpfs-backed Filesystem Session storage
This is not really a good idea for storing sessions, it’s highly
volatile and unstable two things you probably don’t want for ecommerce
store sessions. It’s also not scalable either as it relies on the
machine’s physical memory, and you can only stick so much of that in –
you might need it for the web server too. It will also not help at all
in a clustered environment as it is machine specific.
Despite all it’s limitations I really wanted to test tmpfs sessions
more out of curiosity than anything, I have a hunch that it will make
quite a performance boost. Let’s see how it does in the benchmark
section below.
If you’re keen to try this, I’ll assume you know what you’re doing on the system side of things. Mount var
(or var/sessions
) as a tmpfs
and set Magento to use file based session storage like in the first option above.
No comments:
Post a Comment