跟踪当前在线用户的最佳途径 [英] Best way to keep track of current online users

查看:115
本文介绍了跟踪当前在线用户的最佳途径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网站始终在线显示用户数量的要求。例如,35741用户目前在线。这是不是基于日志中,许多用户只是如何,目前我的网站上。我已经使用会话开始/会话结束此尝试,但是会话结束是不可靠的。因此,我得到膨胀的数字,因为我的会话开始增加了数字,但是,因为它不火会话结束不会删除它们。

I have a requirement that my site always display the number of users currently online. For example, "35741 Users Currently Online". This is not based on a log in, simply how many users are currently on my site. I have tried using Session Start/Session End for this, however session end is not reliable. Therefore I get inflated numbers, as my session start adds numbers but session end doesn't remove them because it doesn't fire.

有是从这个(报告等)收集的任何其他信息,它只是要求数量显示出来。这是变成一个巨大的交易非常简单的请求。任何帮助是AP preciated。

There is no additional information to be gathered from this (reporting, etc), it's simply requested that the number show up. Very simple request that's turning into a huge deal. Any help is appreciated.

编辑:

我要指定我也使用这个数据库的尝试。简单的表包含会话ID和最后一项活动列。每个页面命中,我检查,看看是否会话是在我的数据库。如果没有,请插入。如果是这样,更新活动时间。然后我运行扫数据库寻找最后20分钟没有活动的会话的过程。这种做法似乎杀了我的SQL服务器和/或IIS。不得不重新启动该网站。

I should specify that I have also tried using a database for this. Simple table that contains a session ID and a last activity column. With each page hit, I check to see if the session is in my database. If not, insert. If so, update with activity time. Then I run a procedure that sweeps the database looking for sessions with no activity in the last 20 minutes. This approach seemed to kill my SQL server and/or IIS. Had to restart the site.

推荐答案

最好的办法是像你这样做,而是通过活动的时间出来。如果给定的会话不5分钟左右的时间内访问一个页面,你可能会认为它们不再有效。

Best way is like you do, but time it out via activity. If a given session doesn't access a page within 5 minutes or so, you may consider them no longer active.

这篇关于跟踪当前在线用户的最佳途径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆