Thursday, May 12, 2011

BigPipe

BigPipe is a redesigned basic dynamic web service system. General idea is called Pagelets, decompose the Web into small pieces and then through the Web browser and server to establish the pipeline and manage them at various stages of operation. This is similar to the most modern microprocessor line execution: multiple instruction pipeline through different processor execution unit, in order to achieve the best performance. Although BigPipe is based on existing service network process re-engineering, but it did not need to change the existing web browser or server, it fully use the PHP and JavaScript to achieve.
motivation
To better understand BigPipe, we need to know about the existing dynamic Web service system, it's history can be traced back to the world wide Web, but now the early compared with early but didn't change much. Modern web site has a far higher than 10 years ago, but dynamic and interactive web service system of traditional already unable to keep up with the current Internet speed requirements. In the traditional mode, the life cycle of user requests are as follows:
1. The browser to send an HTTP request to the Web server.
2. Web server parsed request, then read data storage layer, formulate a HTML files, and a HTTP response transmits it to the client.
3. The HTTP response sent to the browser via the Internet.
4. The browser analytical Web server response, use HTML documents to construct a DOM tree, and download the quoted CSS and JavaScript files.
5. CSS resources after download, analytical them, and browser they applied to the DOM tree.
6. JavaScript resources after download, analytical and execute them. Browser
The traditional mode in the modern web site is very low efficiency, because many system operation order, not overlap each other. Some, like delay loading JavaScript, parallel downloads optimization technique has been widely used the online community, in order to overcome some restrictions. However, these optimization rarely involves Web servers and browsers caused execution sequence of bottleneck. When Web server is busy generate a page, the browser are idle, waste its cycle doing nothing. When Web server generated page, and will complete its sent to the browser, the browser will become performance bottlenecks and Web server to its don't help. Overlap with the Web server browser renders generate time time, we could not only reduce the end time delay, also can make Web page display user earlier visible region to the user, thereby significantly reducing the user to delay perception.
Web server comes a time and browser rendering time overlap is particularly useful, such as Facebook so rich content website. A typical Facebook page contains many sources of different data: buddy list, dynamic, advertising, etc. Friends In traditional web present mode of users will have to wait until these inquires the data are to return and generate eventually file, and then sends it to a user's computer. Any inquires the delay will slow down the whole final document is generated.
BigPipe how work
To use the Web browser and server parallelism between BigPipe first breaks down, the Web into multiple calls Pagelets. As the line microprocessor partitioned into a instructions for (such as "the life cycle," instruction fetch "decoded", "executive", "write back to register, etc.) multiple stage, BigPipe page generating process is divided into the following several stages:
1. Request analytic: Web server parsed and completeness inspection HTTP request.
2. Data acquisition: Web server retrieve data from a storage layers.
3. Mark generation: Web server generated response HTML tags.
4. The network transmission: response from Web server sent to the browser.
5. CSS download: browser to download web CSS requirements.
6. DOM tree structure and CSS styles: browser tectonic DOM document tree, then apply its CSS rules.
7. JavaScript download page JavaScript: the browser to download the resources reference.
8. Implementation: the web browser JavaScript executive JavaScript code.
The first three stages, the enforcement by Web server, final four stages is by browser execution. Each Pagelet must pass all these stages, but BigPipe order in different stage of several Pagelets executing simultaneously.
In BigPipe, a user requests life cycle is this: in the browser to send an HTTP request to the Web server. In HTTP requests received, and on some comprehensive examination, the web server immediately returned a open HTML file, including an HTML tags and tag the start tag. BigPipe tags contain the library to parse Pagelet JavaScript received a reply. The tag, have a template, it specifies the page of the logical structure and Pagelets placeholder.
Pagelet in the client through "onPageletArrive after receiving the instructions, BigPipe issued the JavaScript library will be the first to download it CSS resources; In CSS resource was downloaded is completed, Pagelet mark in BigPipe will reveal its innerHTML HTML. More Pagelets CSS available in the same time, they can download according to their respective CSS download completion status to confirm display sequence. BigPipe, JavaScript resources in the priority below CSS and content of a web page. Therefore, BigPipe won't Pagelets displayed in all the Pagelet before downloading any JavaScript. And then, all of Pagelets JavaScript asynchronous download. Finally Pagelet of JavaScript initialization code according to their respective download complete situation determined execution sequence.
This highly parallel system, the final result is more than the Pageletsr different performance stage simultaneously. For example, the browser is being downloaded Pagelets CSS resources, three simultaneously has shown that another Pagelet content, meanwhile, the server is in generating new Pagelet. From the user's standpoint, the page is gradually presents. The first web content will be quicker display, which greatly reduces the time delay of the user to page perception. If you want oneself to see different, and you can try the following link: the traditional mode and BigPipe. The first link is the traditional mode single mode display page. The second link is BigPipe pipeline mode page. If your browser version are older, or slow speeds, the browser cache not beautiful, which yao two pages and cut the time difference between will be more apparent.
User BigPipe performance test shows that in most browsers halved the feel of the delay. 

No comments:

Post a Comment