如何管理页面浏览量数据库
我有兴趣跟踪我的用户在我的网站上的页面浏览量。由于流量增长得非常快,我担心机器人等,而且我也希望能够实时使用跟踪数据来改变用户体验(因此,虽然我确实使用谷歌分析,但它不能用于此目的) 。
存储我的信息最有效的方式是什么?这是我当前的理论,请批评和/或提供更多想法:)
策略:收集 ip、页面 url、浏览器/版本、时间戳、加载时来自客户端的引用并将一行插入 MySQL。根据时间或性能确定某个时间间隔来“归档”表并删除行或通过 cron 创建新行。
这稳定吗?
I am interested in tracking my users' pageviews on my site. Being that traffic is expanding very quickly, I am worried about robots, etc, and I also want to be able to use tracked data live to alter the user experience (so, while I do use Google analytics, it does not serve this purpose).
What is the most efficient way to store my information? Here is my current theory, please critique and/or offer more ideas:)
Strategy: Gather ip, page url, browser/version, timestamp, referrals from client on load and insert a row into MySQL. Determine some interval based on time or performance to "archive" the table and either delete rows, or create a new one via cron.
Is this stable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全确定,但是用户表(也许通过 cookie 或会话分配用户 ID)、页面表(这可能实用,也可能不实用,具体取决于它们的生成方式)怎么样?以及一个跟踪表来显示每个用户 ID 查看哪些页面(通过一些唯一的页面 ID 标识符)?
(等等...)
然后使用简单的 MySQL(或您正在使用的任何数据库)查询来检索哪个用户查看了哪些页面。
主要的弱点是用户将在工作/家庭中拥有不同的标识符(除非您登录),并且每个 IP 地址都有多个用户,并且可能每个 cookie/会话(取决于用户对共享其工作站的开放程度) /件)。
I'm not entirely sure, but how about a table of users (perhaps assign a user-id, via cookie or session), a table of your pages (this may or not be practical, depending on how they're generated), and a tracking table to show which pages (via some unique page-id identifier) each user-id looks at?
(etc...)
Then use a simply MySQL (or whatever DB you're using) query to retrieve which pages were viewed by which user.
The primary weaknesses are that users will have different identifiers from work/home (unless you log them in), and multiple users at each ip-address and, potentially, each cookie/session (depending on how open the users are with sharing their workstations/pcs).
听起来很有道理。如果您希望插入速度尽可能快,则应该将该表设置为 MYIASM 并且不包含任何索引。
Sounds reasonable. You should make that table MYIASM and not have any indexes if you want inserts to be fast as possible.