Facebook的推送数据如何为新闻源?何为、数据、新闻、Facebook

由网友(难得孤寂)分享简介:我很好奇,在Facebook如何将数据推送到浏览器的消息送入。新的数据显示,高达在饲料顶部无需重新加载页面或点击一个按钮难道Facebook的做到这一点通过查询通过AJAX他们的服务器在设定的间隔还是它们在某种程度上推新数据从服务器到客户端无端?如果是的话用什么语言或API做的,他们用它来做到这一点?I am c...

我很好奇,在Facebook如何将数据推送到浏览器的消息送入。新的数据显示,高达在饲料顶部无需重新加载页面或点击一个按钮 难道Facebook的做到这一点通过查询通过AJAX他们的服务器在设定的间隔还是它们在某种程度上推新数据从服务器到客户端无端? 如果是的话用什么语言或API做的,他们用它来做到这一点?

I am curious as to how Facebook pushes data to the browser as in the news feed. New data shows up at the top of the feed without reloading the page or clicking a button Does Facebook achieve this by polling their server through AJAX at a set interval or do they somehow push new data from the server to the client unprovoked? If so what language or API do they use to do this?

推荐答案

它实际上是被称为长轮询,或的彗星。有不同的方式来执行服务器推送,但最常用的方式是保持连接打开,而它接收数据(它有缺点浏览器已经打开连接数限制的主机)。 Facebook的开源的龙卷风Web服务器的,它可以处理大量打开的连接(这可能是一个问题是你有很多用户,但使用Apache为例)。在收到Ajax响应的那一刻,您只需执行一个新的请求,等待下一个响应。

It's actually called 'long polling', or 'comet'. There are different ways to perform server push but the most common way is to keep connection open while it receives data (it has drawbacks as browser have limit of number of open connections to a host). Facebook had open-sourced the Tornado web servers, which can handle a lot of open connections (which can be a problem is you have a lot of users, but you are using apache for example). In the moment you receive AJAX response, you simply perform a new request, waiting for next response.

阅读全文

相关推荐

最新文章