I keep studying this flow of the Facebook's bigpipe technique but I have this question.
How this thing is implemented? does the pagelet is received through an ajax request? I keep on searching for the source code of this bigpipe but it points me to a 404 page of github.
Can someone explain this bigpipe in a low level(programming algorithm) way. I'm really interested with this technique.
Thanks in advance
Although BigPipe is a fundamental redesign of the existing web serving process, it does not require changing existing web browsers or servers; it is implemented entirely in PHP and JavaScript.
How does the Facebook algorithm work? First, Facebook takes every post available in a user’s network (a.k.a. the “inventory”), and it scores those posts according to predetermined ranking signals, like type of post, recency, et cetera. Next, it discards posts that a user is unlikely to engage with, based on that user’s past behaviour.
In BigPipe, the life cycle of a user request is the following: The browser sends an HTTP request to web server. After receiving the HTTP request and performing some sanity check on it, web server immediately sends back an unclosed HTML document that includes an HTML tag and the first part of the tag.
In 2021, the Facebook algorithm is made up of four main ranking signals: recency, popularity, content type, and relationship. Good morning to everyone except for Brian, who just asked the company-wide Slack channel “wow why do our organic Facebook numbers so bad?” Well, Brian, the short answer is the Facebook algorithm. Read on, and we’ll explain.
Well, no, the main content and pagelets are received with the same connection. The pagelets are simply streamed as they are generated to the browser, and placed in the document with Javascript.
You can find an open (and simple) BigPipe implementation in PHP here.
I developed a simple page framework recently. The core idea is to separate a page into several features, each of which will be handled in parallel. The output of each feature is an HTML segment, which the framework then assembles by layout configuration. The first version is not perfect. If you get interested, check here https://github.com/chennanfei/Moonlight
Before explaining in detail how Bigpipe works, I will mention I developed a Django extension that implements Bigpipe. Bigpipe-Response.
I will use Bigpipe-Response code to illustrate how Bigpipe works.
Bigpipe is using the initial connection made by the browser, in the following steps:
The server will send back the HTML.
a. Without closing </BODY></HTML>
tags. This way to browser assumes that the connection is still open.
b. The HTML will contain empty <DIV id="pagelet-1"></DIV>
elements where bigpipe fill a pagelet content.
c. Small javascript at the top of the page is included (see step 3)
At the top of the page, there is a small javascript function that accepts JSON and populates the page with that JSON content. bigpipe.js
renderPagelet
inside the Bigpipe.js
file will use the JSON data to populate the HTML page.</BODY></HTML>
tags. Hope this helps. for more info, you can refer to the documentation Here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With