NYCPHP Meetup

NYPHP.org

[nycphp-talk] files vs. mySQL session handling

Steve Manes smanes at magpie.com
Fri Jan 31 08:42:55 EST 2003


At 08:00 AM 1/31/2003 -0500, Jerry Kapron wrote:
>I just performed some benchmarking and noticed that the default file session
>handler is about 3.5 times faster than one using mySQL on localhost.  I need
>a shared session data storage for multiple web servers, but did not expect
>mySQL session handling to be that much slower than files.  I'm wondering if
>anyone on the list have done anything like that  and would like to share
>their experience.

This makes sense, especially if you don't have a persistent MySQL 
connection.  MySQL has to verify the connection, process the query, hit the 
index, fetch the data and return it to the API.  A 'files' approach just 
needs to open the session file, the data for which is probably already 
cached by the OS.  If you want even more speed, put those session files on 
a RAM disk.

As you said, a MySQL session solution comes into its own when you're 
dealing with multiple web servers, although you could also do it over NFS 
(but NFS is pretty slow too).  Also, the 'files' solution doesn't do a very 
good job of cleaning up after itself.  Thousands of stale session files are 
going to slow down directory search times.

You could build a custom session server which serves session data from a 
memory-bound hash over a socket.





More information about the talk mailing list