Facebook的推送数据如何为新闻源? [英] How does facebook push data to news feed?

查看:197
本文介绍了Facebook的推送数据如何为新闻源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,在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.

这篇关于Facebook的推送数据如何为新闻源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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