对任何正在进行的事件执行评论运行 [英] implementation of running commentary on any ongoing event

查看:35
本文介绍了对任何正在进行的事件执行评论运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找网站上媒体中任何事件正在进行的实现。

I am looking for an implementation of Ongoing of any event in the media in my website.

例如:要更新实时演讲,实时会话,实时足球,板球直播网球等...在我的基于PHP& PHP构建的网站中mysql。

For example: want to update the live speech, live session, live football, live cricket live tennis etc.... in my website which is build on PHP & Mysql.

例如,您可以引用这一个
http://www.espncricinfo.com/icc_cricket_worldcup2011/engine/current/match/433570.html

For example, you can refer to this one http://www.espncricinfo.com/icc_cricket_worldcup2011/engine/current/match/433570.html

本来是想用数据库来实现的,但是如果有100万人访问相同的评论,那么网站变慢的机会就更多,可能是由于同时打开的连接

Iintially thought of implementing this with the Database, but if there are 1 million people accessing the same commentary then chances of becoming website slow is more, may be due to simultaneous connections are open

我认为有一些使用XML功能的方法,如果任何人有任何IDEAS,请与我分享链接或设计,它们可以无条件地帮助我实现这一功能。

I think there are ways of doing with XML features, If any one has ANY IDEAS, please share with me the links or the design, that can defnitely help me in implementing this one.

推荐答案

解决方案概述

由于您一直在处理实时数据,因此无需出于存档目的,将其存储在数据库中。您应该有一个应用程序范围的缓冲区,其中包含每个频道(板球,网球,足球等)的当前评论。要在页面上显示该评论,应使用 ajax轮询。不要选择推送模型,因为它会使服务器超载。

Solution Overview
Since you are dealing with live data all the time, there is no need to store it in a database other than for archival purposes. You should have an application scoped buffer that holds the current commentaries for each of the channels (cricket, tennis, football etc.) For displaying it on the page, you should use ajax polling. Don't go for a push model as it can overload the server.

工作原理

对于缓冲区,我建议使用队列数据结构。 (从外部系统或有人输入的)注释的每一行都应使用唯一的行号添加到队列中。浏览器中的javascript代码始终请求自最后显示的行以来的所有新行,这些行应在浏览器中的javascript变量或隐藏变量中维护。随着队列的增大,服务器端可以具有一个或多个线程,这些线程从队列中读取最旧的条目并将其写入数据库进行归档(如果需要此功能)。

How it works
For the buffer I would recommend a queue data structure. Each line of commentary that is created (from an external system or somebody is typing it in) should be added into the queue with a unique line number. The javascript code in the browser always requests for all new lines since the last displayed line, which should be maintained on the browser in a javascript variable or in a hidden variable. As the queue grows big, you can have one or more threads in your server side that reads the oldest entries from the queue and writes them to a database for archival (if you need the feature).

性能调整

队列的大小,归档线程数等是需要调整的参数根据用户数量,可用内存和可接受的容错行来确定行数(某些客户端可能会在队列存档速度过快时有时会漏掉某些行)。如果您知道这些数字,则可以使用排队理论概念来获得最佳值队列大小和线程数。

Performance Tuning
The size of the queue, the number of archival threads etc. are tuning parameters that needs to be worked out based on the number of users, the available memory and accepted tolerance for missing lines (some clients can miss out some lines at times when the queue is getting archived too fast). If you know these numbers, you can use queuing theory concepts to arrive at the optimum queue size and thread counts.

这篇关于对任何正在进行的事件执行评论运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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