I am looking for the best way to keep a near real-time accounting of the number of users on my website. This is in a LAMP environment and I would like to build a solution that uses JavaScript on the front end and PHP/MySQL on the back end. My end goal here is to have a MySQL table that has a record for each active user.
My current idea for gathering that information is to simply include a piece of javascript on each page that runs an AJAX request that then creates the record for that user. In order to ensure that I have a unique record for each user, I plan on creating a PHP session for each user.
My question is: If I am creating a php session for each active user, will this cause a performance issue on a run-of-the-mill VPS if there is, for example, 1,000 connected users? Is there a better way to have a unique record for each user (i.e. accounting for users behind a NAT) without creating a PHP session?