I'm assuming you're running this thing on *nix.

Session variables are stored on the file system. PHP writes them out to /tmp, where it subsequently reads them upon request. The question is: How good at caching is your DB? If it can cache common select queries, then you are probably better using the DB (since file system caching is usually not that great). If your DB is busy with other things while the file system is relatively idle, maybe it'd be better to store them in sessions.

The only real way to know is to benchmark both methods. You could come up with some real quick code that implements both methods. Then, run ApacheBench (ab) or JMeter to test the performance. Be sure that you run the benchmark utility in such a way to use the session vars (ie, simulate a user login). During the tests, watch things like load average (top) and I/O activity (iostat).

Let us know which method works best for you. Scalability issues are so cool.


Chris Payne wrote:
Hi there everyone,

I have a system I am programming, and each page needs to get various config
elements from a DB, of course this means lots of DB access for each page.
What I was wondering is, after the user has logged in successfully it
currently stores their email, name, address and a few other bits of data in
a session, would it also be a good idea to store other information in a
session at the very start when they login to ease DB access?  Are there
problems with having lots of data in a session?  Well when I say lots of
data, I mean things like font size, color, table images, background colors,
some normal text etc .... nothing like an essay or anything, just about
30-50 different variables.

Just want to make sure it won't slow my system down by doing this, or would
it speed it up because of less DB access?

Thanks for your help



PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to