Portal Home > Knowledgebase > Articles Database > Users online?

Users online?

Posted by Jona102190, 06-26-2007, 09:41 PM
Would anyone know the easiest yet most efficient method of doing a users online script? I'm not asking for the code, just the jist of the content. I made a script months ago to query a mysql table, and check if the IP is there, if it is, renew it (the time would be a collum) for 5 minutes, else add it. Periodically deleting unupdated rows, and just counting the number active for the users online. I doubt this is the best way. I want to handle possibly 5-10k+ users. :-/ Any ideas? Thanks.

Posted by Crucial Web Host, 06-27-2007, 01:26 PM
If you store your sessions in a session table you could just do a count on that table to get active sessions - Dont know enough about your setup to really provide much help. Rick

Posted by mwatkins, 06-27-2007, 01:43 PM
What you propose is basically what you need to do. Your session implementation should have a creation_time and an access_time or similar date fields, and you update access_time as each request comes in... a periodic script should purge requests where creation_time - access_time > lease_time (whatever period you decide - 5 minutes or 30 minutes or whatever). For 99% of all web architectures out there in current use, that's what you've got to work with, because you've no idea if they've walked away, closed their browser, or shut off their machine. The downside to such schemes is you are going to be doing a lot of updates (unavoidable with most web architectures) to your session data table. If running some sort of persistent process (like a Ruby or Python web app) then I would keep all the session data in RAM and persist it to a DB or file on application shut down only.

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
heeeeeeeeelp !!! (Views: 258)