Re: [PHP4BETA] Session garbage collection
| From: | Sascha Schumann | Date: | Mon, 13 Dec 1999 11:22:36 +0000 |
| Subject: | Re: [PHP4BETA] Session garbage collection | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-7847@lists.php.net to get a copy of this message | ||
On Mon, Dec 13, 1999 at 01:40:08PM +0100, Hans Rakers wrote:
> Hi all,
>
> I'm implementing php4 session management in a huge website we're
> developing. Now i want to start a session for every visitor hitting our
> website, but i'm wondering about whether it is a smart thing.
>
> Php4 is configured to write session files to a directory on a EXT2 partition,
> and i don't know the limitations for this type of file system, but when there's
> lots of visitors in a small timespan this might get tricky. So my question is
> how often do old, unused registered sessions get purged? Do i really run into
> trouble in this situation? Or should i use a different type of filesystem for
> storing session files?
ext2fs can be used to store session information. If you worry
about having millions of directory entries, you can enable
hashing, so that the session module distributes the files
over multiple directories.
The following steps have to be performed to store the data in
/sessions and to enable a hash-depth of 2 directories.
1.) Configure PHP:
session.save_path = 2:/sessions
session.save_handler = files
2.) Create the directories:
$ mkdir /sessions
$ sh php-4.x/ext/session/mod_files.sh /sessions 2
3.) Set up a cron job to expire old session files (if the
hash-depth is > 0, this is currently not performed by the
session module because of efficiency reasons). For example,
to expire files older than 1 day every hour:
23 * * * * find /sessions -ctime +1 -exec rm {} \;
--
Regards,
Sascha Schumann
Consultant