In our application, we store the most number of users online. We do this by tracking what page each user is on currently and upon login, delete users who have been inactive for X minutes and then take a count of the users online, overwriting the most number online if this is higher.
How can we change this to track the number of users online over a time period, so we can look at a line graph of the number of users online. I guess we’ll need a cron to run every 1/2/5/10/20/30/60 minutes to track the number online? Then how would be store this data, the table would get very large. I would think the likes of Statcounter/Analytics would have a better way of storing this data.
Any pointers would be appreciated.
There is no way to store it in less space. If you have a long period of time, you have a certain amount of data. It depends on the number of logins and length of intervals, whether you better store logins or samples of user count.
Just store it with the highest sampling rate you need, it’s easy to group it for example by hour later: