Re: Counting Online users, but not using a Session Table in MySQL
| From: | Jim Lucas | Date: | Fri, 28 Jan 2011 19:53:30 +0000 |
| Subject: | Re: Counting Online users, but not using a Session Table in MySQL | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311078@lists.php.net to get a copy of this message | ||
On 1/28/2011 11:23 AM, David Harkness wrote:
> On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay <marc.guay@gmail.com> wrote:
>
>> If COUNTing is the heavy part, why not create a 'users_logged_in'
>> field somewhere and increment it when someone logs in and decrement it
>> when someone logs out? Then your query is just a straight SELECT.
>
>
> If this is like most web sites, users don't usually log out--they just stop
> requesting pages. With no logout event to decrement the count you need some
> other way to stop counting a particular user such as 30 minutes after they
> logged in. This is easily handled in a query on the users table, but it
> causes performance issues.
>
> David
>
cron it.
Setup a cron script that runs every 5 minutes.
A seconds work every 5 minutes isn't too much is it?
Jim Lucas