收集大量视频观看数据
我想向基于 Flash 的媒体播放器添加跟踪,以便我们可以提供分析来显示正在观看的视频部分(目前,我们只是在视频开始播放时注册视图)
例如,如果观看者观看视频的前 30 秒,然后点击其他内容,我们希望数据能够反映这一点。
同样,如果有人观看了前 10 秒,然后将时间线拖到视频的最后一分钟并观看,我们希望记录观看的部分而不是中间部分。
我的第一个想法是收集播放器中的观看数据,并在观看会话结束时将其全部发送到服务器。不幸的是,Flash 似乎没有一个当观众点击电影所在页面时您可以挂钩的事件(可能是一件好事 - 它可能会被滥用)
所以,看起来我们将必须在视频播放时定期向服务器发出请求。当有大量同时观看者时,这显然会导致大量请求。
将所有这些“心跳”事件从客户端转储到数据库的简单方法感觉很快就会变得难以管理,所以我想知道是否应该采取一种方法,将查看会话缓存在内存中,并在它们变得不活动时刷新到数据库(基于超时)。这样,数据就可以存储为时间跨度而不是单个心跳。
那么,对于这个问题 - 处理这种大量观看数据的最佳方法是什么?是否有任何好的现有架构/模式?
谢谢,
丹。
I want to add tracking to our Flash-based media player so that we can provide analytics that show what sections of videos are being watched (at the moment, we just register a view when a video starts playing)
For example, if a viewer watches the first 30 seconds of a video and then clicks away to something else, we want the data to reflect that.
Likewise, if someone watches the first 10 seconds, then scrubs the timeline to the last minute of the video and watches that, we want to register viewing on the parts watched and not the middle section.
My first thought was to collect up the viewing data in the player and send it all to the server at the end of a viewing session. Unfortunately, Flash does not seem to have an event that you can hook into when a viewer clicks away from the page the movie is on (probably a good thing - it would be open to abuse)
So, it looks like we're going to have to make regular requests to the server as the video is playing. This is obviously going to lead to a high volume of requests when there are large numbers of simultaneous viewers.
The simple approach of dumping all these 'heartbeat' events from clients to a database feels like it will quickly become unmanageable so I'm wondering whether I should be taking an approach where viewing sessions are cached in memory and flushed to database when they become inactive (based on a timeout). That way, the data could be stored as time spans rather than individual heartbeats.
So, to the question - what is the best way to approach dealing with this kind of high-volume viewing data? Are there any good existing architectures/patterns?
Thanks,
Dan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用 Flash Media Server 进行流式传输?如果是,服务器可以为您做所有这些事情。
Are you using Flash Media Server for streaming ? If yes the server can do all this things for you.
您可以使用 javascript 'onbeforeunload' 挂钩来捕获页面退出。您还可以将其与一些 flash/js 交互结合起来,以聚合所有数据并批量发送。
You can use the javascript 'onbeforeunload' hook to trap page exits. You can also combine this with some flash/js interaction to aggregate all the data and send it in one batch.