mootools:我想在Facebook上实现类似于Big pipe的架构 [英] mootools: I want to implement architecture similar to Big pipe in Facebook

查看:78
本文介绍了mootools:我想在Facebook上实现类似于Big pipe的架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个mootools应用程序。我使用了Reqeust类来实现流水线操作。
我想开发一种处理客户端服务器请求的高级方法。我参考了以下文章,了解大型管道在facebook中的工作原理。

I am developing an application in mootools. I have used Reqeust class to implement pipelining it. I want to develop a superior method to handle client server requests. I referred the following article to understand how big pipe works in facebook.

http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-性能/ 389414033919

在Facebook中,在更新数据用户屏幕的任何服务器响应到达时调用javascript函数。 (见截图)

In facebook, a javascript function is called on arrival of any server response to update data user screen. (see the screenshot)

http ://img815.imageshack.us/img815/5154/facebookna.jpg

如果我得到这样的架构的基本模型,我可以开始构建应用程序使用那个
代码。

if i get a basic model of such architecture, i can start building application using that code.

有人能为我提供这样一个基本型号吗?

can some one please provide me such a basic model?

直到现在我已经设计了一个架构,其中response_data存储在一个全局变量中,然后调用一个函数来将数据更新到用户屏幕。(在这里使用同步请求)非常慢。

Till now i have designed an architecture in which response_data is stored in a global variable and then a function called to update data to user screen.(Used synchronous Request here) which is very slow.

那么哪种方法优于'同步或异步'?

so which method is superior 'synchronous or Asynchronous'?

推荐答案

首先,感谢阅读,这是一个非常有趣的博客文章。

Firstly, thanks for the read, it was a very interesting blog post.

您可能需要查看此图书馆的灵感来自Facebook的BigPipe。注意:我不支持它,因为我从未使用它,但是自己构建它并不是一件容易的事。

You may want to look into this libary which was inspired by Facebook's BigPipe. Note: I'm not endorsing it as I've never used it, but building it yourself is not trivial.

关于同步和异步是否更好,要看。同步是更简单 - 依赖性是显而易见的,并且没有开销。如果您的资源没有得到充分利用,异步只是一个优势,您的处理可以很容易地分解为独立的块。我不知道你要做什么,所以你需要自己决定性能瓶颈的实际位置,以及构建应用程序以便可以并行下载,处理和呈现多个部分实际上会提供一个优点。

With regards to whether synchronous and asynchronous is better, that depends. Synchronous is simpler - the dependencies are obvious, and there's no overhead. Asynchronous is only an advantage if your resources are not fully utilised, and your processing can be easily broken down into independant blocks. I can't tell what you're trying to do, so you need to make the decision yourself where the performance bottleneck actually is, and whether architecting your application such that multiple sections can be downloaded, processed and rendered in parallel will actually provide an advantage.

例如,如果您要下载一个庞大的数据块,将其作为表格在浏览器中呈现,那么将该数据分成多个并行下载将提高性能 - 代价是创建一些排队系统来处理乱序响应。另一方面,虽然在技术上较慢,但是将下载批处理为同步块以便在下一个块被请求之前下载并呈现一个块,仍然会对感知性能产生奇迹,并且更加简单另类。

As an example, if you're downloading a single, massive block of data to be rendered as a table in the browser, then breaking that data into multiple parallel downloads will improve performance - at the cost of creating some queuing system to deal with out-of-order responses. On the other hand, though technically slower, batching the download into synchronous blocks so that one block is downloaded and rendered before the next one is requested, will still do wonders to perceived performance, and is a much simpler alternative.

这篇关于mootools:我想在Facebook上实现类似于Big pipe的架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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