简体   繁体   English

什么是制作活动记录器的最佳方法

[英]What is the best approach to make a Activity Logger

I am writing a Activity tracker for a grails application. 我正在为grails应用程序编写活动跟踪器。 Objective : To Log Usage Hours and browsed pages so that I can analyse logged in user's activity pattern. 目标:记录使用时间和浏览页面,以便我可以分析已登录用户的活动模式。

My current planned solution : Make two tables, One named 'activity', second 'browsed_page' Activity table will store user_id, jsessionid, date_created, validtill. 我当前计划的解决方案:制作两个表,一个表名为“ activity”,第二个表名为“ browsed_pa​​ge”。活动表将存储user_id,jsessionid,date_created,validtill。 and browsed_page will have activity_id and browsed_url. 并且browserd_page将具有activity_id和browserd_url。 The javascript on every pages will be executed for checking mouse activity every 5 minutes, if it detects mousemove, it will make a ajax request to the conroller and the controller logs accordingly. 每5分钟将执行每页上的javascript以检查鼠标活动,如果它检测到mousemove,它将向控制器发出ajax请求,并且控制器将相应地进行日志记录。

Initially, validtill will be 5 minutes plus the date_created, which will be updated to be current_time + 5 minutes, if the activity is detected and ajax request is made. 最初,如果检测到活动并发出ajax请求,则validtill将是5分钟加上创建的日期,该日期将被更新为current_time + 5分钟。

My question : Is this system reliable performance wise? 我的问题:该系统可靠的性能明智吗? I mean, after every 5 minutes, or new page browsed, update is run on activity table to update validtill time. 我的意思是,每隔5分钟或浏览新页面后,将在活动表上运行更新以更新有效时间。 When the application grows and it starts having millions of records, will those updates hamper the performance? 当应用程序增长并开始具有数百万条记录时,这些更新是否会影响性能? Can I get some suggestion what can I do to improve my system? 我可以得到一些建议,如何做才能改善我的系统?

I would skip the part about mouse movements and just piggy back the usage statistics onto the normal actions the user does against your application. 我将跳过有关鼠标移动的部分,而只是将使用情况统计信息放到用户针对您的应用程序执行的常规操作上。 I guess that almost all interaction on the site generates a call to to the application. 我猜想该站点上几乎所有的交互都会调用该应用程序。

Make sure that tracking is configurable so that you can turn it off if it hogs the system. 确保跟踪是可配置的,以便您在跟踪系统时将其关闭。

When it comes to tables I believe in doing it in just one table that you only ever write to. 当涉及到表时,我相信只能在您只写过的一个表中进行操作。 No updates, searches or deletes. 没有更新,搜索或删除。 That is the cheapest way of doing it. 这是最便宜的方式。

Then you would do analysis "off line", possibly on a statistics replica of the database. 然后,您可能会在数据库的统计副本上进行“离线”分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM