简体   繁体   English

mootools:我想在Facebook上实现类似于Big pipe的架构

[英]mootools: I want to implement architecture similar to Big pipe in Facebook

I am developing an application in mootools. 我正在开发一个mootools应用程序。 I have used Reqeust class to implement pipelining it. 我使用了Reqeust类来实现流水线操作。 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. 我参考了以下文章,了解facebook中的大管道是如何工作的。

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

In facebook, a javascript function is called on arrival of any server response to update data user screen. 在Facebook中,在任何服务器响应到达更新数据用户屏幕时调用javascript函数。 (see the screenshot) (见截图)

http://img815.imageshack.us/img815/5154/facebookna.jpg 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? 有人能请我提供这样一个基本型号吗?

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. 到目前为止,我已经设计了一个体系结构,其中response_data存储在一个全局变量中,然后调用一个函数来将数据更新到用户屏幕。(在这里使用同步请求)非常慢。

so which method is superior 'synchronous or Asynchronous'? 那么哪种方法优于'同步或异步'?

Firstly, thanks for the read, it was a very interesting blog post. 首先,感谢阅读,这是一篇非常有趣的博文。

You may want to look into this libary which was inspired by Facebook's BigPipe. 您可能想要查看受Facebook的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. 另一方面,虽然技术上较慢,但是将下载批量处理为同步块以便在下一个块被请求之前下载和呈现一个块, 仍然会对感知性能产生奇迹 ,并且是一种更简单的替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM