Jump to content

Recommended amount of variables stored in a session ?


inVINCEable

Recommended Posts

Kind of a general question but I could not find a concrete answer anywhere. Right now at any given time my site has about 10,000 concurrent users. I make good use of the $_SESSION variable, and use it to do all sorts of things from inserted the user_id stored in the session into hidden fields etc. Right now my concern is I am storing about 30 variables per user in each session. About 20 of these are just basic things like the user's settings. My question is, how much of a performance hit am I taking by storing this many variables in the session? Should I look at possibly moving the user settings to the DB instead?

 

 

Thanks for any advice on the subject.

Link to comment
Share on other sites

i think as long as the session_start() is at the top of every page and the information is kept by the session it fine

when they get to the bit where the database needs updating then update as needed.

 

remember to unset all session's when update has be done.

 

 

Link to comment
Share on other sites

Ok from what you said it depends, if each user takes about 10kilobytes worth of settings (mostly strings) stored in a session var then when u mutiply that by 10,000 then it turns into 100megabytes of space on the harddrive which could need to be changed very freaquently so it depends on how fast the PC is and how much ram it has that the server runs on, also i think you should try to use a database as much as possible but im also inexperenced lol (also im sure its more liek numbers and not really long strings just stating worse scenario)

Link to comment
Share on other sites

I can't really be of help other than to bump this as it's an issue I think about alot too. there's always a trade off in how many sql calls to make, how much cpu to eat, how much memory to use.

 

I'm curious, with 10k concurrent users, currently with the way you're doing things what sort of drain does thta cause for you, ie what sort of server /plan do you run that from? what type of site is it?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.