Re: PHP and Linux performance tweaks

From: Date: Sat, 08 Sep 2001 23:15:17 +0000
Subject: Re: PHP and Linux performance tweaks
References: 1  Groups: php.install 
Request: Send a blank email to php-install+get-4251@lists.php.net to get a copy of this message
> I am helping someone to reconfigure PHP for a high-traffic site (well... > high traffic for one PC to handle, at least). > > The server is hosted by Rackspace.com, running Linux kernel 2.2.19. I have > done all the standard Apache/PHP/MySQL performance tweaks, and I have raised > the filesystem and inode limits in /proc/sys/fs. > > I have read that one performance tweak for Linux is to mount the filesystem > with the "noatime" option (meaning the kernel does not update the timestamp > whenever files are accessed). > > The site relies highly on PHP sessions, and it seems to me that there would > be trouble with the /tmp/ session files if I configure Linux to mount the > filesystem with the "noatime" option. As I understand it, the PHP session > mechanism runs a "stat" operation every time it evaluates whether to delete > session files. This being the case, I guess the logical assumption here is > that it reads the access timestamp to decide whether to delete the session > file or not. > > Am I right here? Is there any way to use the default session mechanism if I > mount the filesystem with noatime? If not, is my only option to create a > custom session handler? > > Also, is there any problem using a RAMdisk partition for the directory to > handle the session files. I suppose theoretically it would be possible to > mount the main filesystem with "noatime", but to create a RAM partition > which *does* update the access timestamp, and have PHP use that for the > session files. You could use the shared memory session store. ie. session.save_handler = mm Or you could create a ramdisk and point PHP at that. session.save_path = /your/ramdisk But yes, if you use the standard "files" save_handler on a filesystem that does not set the atime it will not work. You can see that for yourself in the ext/session/mod_files.c file in the ps_files_cleanup_dir() function: /* check whether its last access was more than maxlifet ago */ if (VCWD_STAT(buf, &sbuf) == 0 && (now - sbuf.st_atime) > maxlifetime) { VCWD_UNLINK(buf); nrdels++; } Of course, you could set the gc to 0 and do your own garbage collection on your session files by some other criteria. Not quite sure how you would determine old and non-active sessions without an atime though. -Rasmus

« previous php.install (#4251) next »