Problem Statement - Would like to know if particular web app user is active (i.e. logged in and using site) and be able to query for list of active users or determine a user's activity status.
Constraints - Doesn't need to be exact (i.e. if a user was active within a certain timeframe, that's ok to say that they're active even if they've closed their browser).
I feel like there should be a design pattern for this type of problem but haven't been able to find anything here or elsewhere on the web.
Approaches I'm considering:
Maintain a table that is updated any time a user performs an action (or some subset of actions). Would then query for users that have performed an action within some threshold of time.
Try to monitor session information and maintain a table that lists logged in users and times out after a certain period of time.
Some other more standard way of doing this?
How would you approach this problem (again, from a design pattern perspective)?
Thanks!