Best way to keep track of current online users(跟踪当前在线用户的最佳方式)
问题描述
我要求我的网站始终显示当前在线的用户数量.例如,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.
无需从中收集其他信息(报告等),只是要求显示数字.非常简单的请求变成了一笔巨大的交易.任何帮助表示赞赏.
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.
这篇关于跟踪当前在线用户的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:跟踪当前在线用户的最佳方式
基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01