Re: mysql sessions vs flat file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Morehouse wrote:
> Has anyone had an experience with storing sessions in mysql (or sqlite)?

Yes, in MySQL.

>   If so, what if any are the performance benefits?

This depends on *SO* many factors...

Is your MySQL database pretty small?

Is your site heavy traffic?

Are most of your sessions short-lived?

Will the MySQL data end up being in RAM and cached?

Sooner or later, the MySQL stuff has to hit the hard drive, one way or
another -- But the user perception could be *MUCH* faster if MySQL caching
is reducing disk access over the course of a short session.

> Obviously, there
> would have to be an extra db query per page... but would that be faster
> then opening a text file?

If you're on a high-traffic site, only some benchmark tests on your
hardware is going to tell you for sure.

If you're not, the MySQL solution is not going to be noticably
slower/faster than the file-based sessions, if you're already opening a
MySQL connection anyway.

If you're *NOT* already making a MySQL connection, then you'd have to test
and see which is faster -- or not worry too much about it, as they'll be
pretty close, and on a low-volume site it won't matter which you use from
a performance perspective.

I haven't tried SQLite, but I suspect it's going to be about the same.


Also an alternative viewpoint to another poster:

If you are writing the MySQL scripts to control sessions, and if you
understand how the sessions work (which takes some doing) then, in my
experience, you can debug session problems easier and faster, because you
already have "hooks" in place to track where stuff is coming from and
going to.

Granted, this assumes you've got a good clean working SQL-based session
setup in the first place, which is several days, perhaps even weeks of
work for the beginner, before they really understand all the bits and
pieces and ins and outs of the session data moving around.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux