The introduction of the BigPipe Facebook pyramid system

I recently read an article article about my new page pipeline system. There are currently several Github projects with similar implementations, but they are all written in Php.

What is BigPipe?

BigPipe is the system with which Facebook came up with the idea that pages seem to load faster. One page is divided into small pages, so it looks like where each box is a page: enter image description here

So, the logic for loading the entire web page turns into:

  • The first request to the server with the client, the html skeleton generated very quickly, has javascript with a big tube.
  • When the client receives the HTML skeleton, it runs javascript BigPipe.
  • As long as the connection with the server remains constant, prospectuses are discarded through the channel to the client and displayed using javascript in bigpipe format.
  • HTML, CSS, and JS for each page are loaded and displayed when they are accepted, so each brochure is loaded separately, giving a faster loading experience.

Their data shows an increase in load time of 2 pages.

Problem

The main problem with implementing this in Pyramid is that I did not find a way to maintain a constant HTTP connection with the client so that it can clear these "prospectuses" through the pipe. I experimented with response.app_iter , but the generator outputs are not reset, most likely the whole response is generated, and then is reset immediately down the pipe. Is there a way to reset multiple β€œresponses” to a persistent connection with Pyramid?

+6
source share
1 answer

From here: https://webob.readthedocs.org/en/latest/differences.html?highlight=stream

This may cause CherryPy to send the source directory of the response. There is no direct equivalent; you can use a dynamically generated iterator to do something like this.

Pyramid uses the webob library to model requests and responses, from the documentation for which the above quote is given. Accordingly, I would say that there is no way to do this using the "Standard" pyramid / pylons.

Instead, you will have to use another library to handle responses (and possibly requests). This may give you some ideas on how to do this: http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/designdefense.html

Alternatively, you can try to subclass the response object to add this functionality, possibly delegating code from another library that supports it.

You should probably choose a library that supports this and ask on the Pyramid mailing list how best to connect this.

+1
source

Source: https://habr.com/ru/post/947178/


All Articles