42

Is it because it requires the responses to be made to client in the order of request that causes the head of line blocking problem in HTTP 1.1?

If each request takes exactly an equal amount of time, then there won't be head of line blocking and HTTP 1.1 pipelining and would perform same as that of HTTP/2 multiplexing?

(let's say there is no request priority in HTTP/2 requests and disregard other changes of HTTP/2 such as header compression, binary, etc.)

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
prasun
  • 7,073
  • 9
  • 41
  • 59
  • See also [How does HTTP2 solve Head of Line blocking (HOL) issue](https://stackoverflow.com/q/45583861/3075942) and [What does multiplexing mean in HTTP/2](https://stackoverflow.com/q/36517829/3075942) – user Aug 12 '18 at 07:49

3 Answers3

79

HTTP/1.1 without pipelining: Each HTTP request over the TCP connection must be responded to before the next request can be made.

HTTP/1.1 with pipelining: Each HTTP request over the TCP connection may be made immediately without waiting for the previous request's response to return. The responses will come back in the same order.

HTTP/2 multiplexing: Each HTTP request over the TCP connection may be made immediately without waiting for the previous response to come back. The responses may come back in any order.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
  • 7
    This is very useful when you read about HTTP v2 and trying to understand the difference between multiplexing and pipelining. Thanks man! – Combine Oct 28 '16 at 13:19
  • Awesome, glad it helped you out! It helped me out too! – Elijah Lynn May 19 '17 at 21:14
  • 1
    So the response will come back in any order instead of the same order. That's the difference. – Konrad Sep 24 '18 at 07:31
  • One thing I don't get is that why the responses have to come back in the same order? what it means by "come back in the same order". Is it mean that only after the server sent all its packets for the first request and the client acknowledges the server and then the server can start to send the second response? – Vimniky Luo Feb 24 '21 at 06:34
44

HTTP/1.1 pipelining still requires the requests to be returned in full, in the order requested.

HTTP/2 allows the requests responses to be split into chunks and be returned in an intermingled fashion so avoiding head of line blocking.

Additionally HTTP/1.1 pipelining never really took off and browser and server support is limited (see: https://en.m.wikipedia.org/wiki/HTTP_pipelining).

But yes, in theory, they are similar and hence give similar performance benefits. HTTP/2 is just a better, more fully featured, more supported version of this - along with other benefits that you've noted.

See also my answer here for a deeper discussion on HTTP/2 multiplexing: What does multiplexing mean in HTTP/2

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
  • Explains all the facts. Thanks :) – prasun Dec 28 '15 at 06:29
  • 2
    And I want to add that HTTP pipelining is not supported by most of the servers because it's hard to implement it and there are some very risky security issues. For example, http smuggling can be done by tampering with Content-Length header of the request and putting multiple requests in a single request and making the proxy server behave wrongly by making it return another user's response to you (because the request order shall be maintained and you just put 2 requests in a single request). This attack requires good timing though but not impossible of course.. anyways :) – yakya Jan 18 '17 at 13:26
  • @sotn please elaborate. Is this real? Who is tampering? – Tuntable Oct 16 '18 at 08:51
  • @Tuntable https://i.blackhat.com/USA-19/Wednesday/us-19-Kettle-HTTP-Desync-Attacks-Smashing-Into-The-Cell-Next-Door.pdf – Amey Jul 11 '20 at 07:44
2

I think to elaborate, both offer similar performance improvements.

However pipelining (or double buffering) is hampered by buggy proxies and sometimes buggy servers. So browsers stopped supporting it.

The solution is to use a completely new protocol HTTP/2. This has a few extra features, such as out of order return, header compression and server push, but it is unclear how much improvement they provide. The key issue is the bugs.

Tuntable
  • 3,276
  • 1
  • 21
  • 26