Welcome to WebmasterWorld Guest from 54.82.29.141

Forum Moderators: open

Message Too Old, No Replies

PHP Sessions & Hard Drive integrity

Creating and unsetting many sessions; impact on hard drive

     
9:44 pm on Jun 6, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 1, 2008
posts:157
votes: 0


Hello,

I've noticed that I'm using sessions quite a bit to keep track of data and plan on undertaking a project that will use even more sessions. From what I understand, when a session is created a file is also created on the server. My use of sessions involves creating them, and then unsetting them when I'm done with them; sometimes this unsetting occurs at the end of a page, sometimes soon after the session is created.

I'm concerned that all this session setting and unsetting will cause the hard drive to become heavily fragmented; especially with large amounts of traffic. Is there need for concern here or should I proceed with my project?

Thank you.

2:51 am on June 7, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


If this is a Linux server, it won't be a problem at all. Linux is equipped to handle a large number of files, and fragmentation is rarely an issue, if ever.

Windows can choke on a folder with thousands of files, but if the overall site/server performance is good, the sessions really shouldn't make much of a difference.

3:26 am on June 7, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 1, 2008
posts:157
votes: 0


Thank you mcavic. It will be a Linux server.
12:53 am on July 5, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 3, 2008
posts:96
votes: 0


sometimes this unsetting occurs at the end of a page, sometimes soon after the session is created.

You might want to look into using memcache [php.net] (it provides a session.save_handler) , especially if you're creating and deleting sessions within the same request often.

Sessions don't have to be saved on disk.

4:35 am on July 9, 2009 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts:2937
votes: 24


If there is no need to keep sessions during a server reboot, you can create a partition as an automatically sizing ramdisk with the tmpfs attribute in /etc/fstab and mount this partition at the location where you normally store your sessions. See man mount for more details.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members