How does HTTP2 solve Head of Line blocking (HOL) issue












9















How does HTTP2 solve Head of Line blocking (HOL) issue?



This problem is very frequent in http1.1, but I heard HTTP2 has fixed this problem. Could someone explain how exactly HTTP2 fixed the problem?










share|improve this question























  • Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

    – sbordet
    Aug 9 '17 at 7:38











  • is SPDY and HTTP2 same? not sure about SPDY!

    – nagendra547
    Aug 9 '17 at 17:14











  • SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

    – sbordet
    Aug 9 '17 at 20:28






  • 1





    So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

    – nagendra547
    Aug 10 '17 at 7:29











  • That is correct. However, the HOL discussion there applies to HTTP/2 as well.

    – sbordet
    Aug 10 '17 at 7:48
















9















How does HTTP2 solve Head of Line blocking (HOL) issue?



This problem is very frequent in http1.1, but I heard HTTP2 has fixed this problem. Could someone explain how exactly HTTP2 fixed the problem?










share|improve this question























  • Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

    – sbordet
    Aug 9 '17 at 7:38











  • is SPDY and HTTP2 same? not sure about SPDY!

    – nagendra547
    Aug 9 '17 at 17:14











  • SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

    – sbordet
    Aug 9 '17 at 20:28






  • 1





    So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

    – nagendra547
    Aug 10 '17 at 7:29











  • That is correct. However, the HOL discussion there applies to HTTP/2 as well.

    – sbordet
    Aug 10 '17 at 7:48














9












9








9


6






How does HTTP2 solve Head of Line blocking (HOL) issue?



This problem is very frequent in http1.1, but I heard HTTP2 has fixed this problem. Could someone explain how exactly HTTP2 fixed the problem?










share|improve this question














How does HTTP2 solve Head of Line blocking (HOL) issue?



This problem is very frequent in http1.1, but I heard HTTP2 has fixed this problem. Could someone explain how exactly HTTP2 fixed the problem?







http networking tcp http2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 9 '17 at 7:09









nagendra547nagendra547

1,719721




1,719721













  • Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

    – sbordet
    Aug 9 '17 at 7:38











  • is SPDY and HTTP2 same? not sure about SPDY!

    – nagendra547
    Aug 9 '17 at 17:14











  • SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

    – sbordet
    Aug 9 '17 at 20:28






  • 1





    So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

    – nagendra547
    Aug 10 '17 at 7:29











  • That is correct. However, the HOL discussion there applies to HTTP/2 as well.

    – sbordet
    Aug 10 '17 at 7:48



















  • Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

    – sbordet
    Aug 9 '17 at 7:38











  • is SPDY and HTTP2 same? not sure about SPDY!

    – nagendra547
    Aug 9 '17 at 17:14











  • SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

    – sbordet
    Aug 9 '17 at 20:28






  • 1





    So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

    – nagendra547
    Aug 10 '17 at 7:29











  • That is correct. However, the HOL discussion there applies to HTTP/2 as well.

    – sbordet
    Aug 10 '17 at 7:48

















Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

– sbordet
Aug 9 '17 at 7:38





Duplicate of stackoverflow.com/questions/25221954/spdy-head-of-line-blocking ?

– sbordet
Aug 9 '17 at 7:38













is SPDY and HTTP2 same? not sure about SPDY!

– nagendra547
Aug 9 '17 at 17:14





is SPDY and HTTP2 same? not sure about SPDY!

– nagendra547
Aug 9 '17 at 17:14













SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

– sbordet
Aug 9 '17 at 20:28





SPDY was the predecessor of HTTP/2. The protocols are so similar that for the HOL problem they could be treated the same. The SPDY answer applies to HTTP/2 as well.

– sbordet
Aug 9 '17 at 20:28




1




1





So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

– nagendra547
Aug 10 '17 at 7:29





So far I can see after googling, SPDY was an experimental protocol and was used to test out things in the real to drive forward the work on HTTP/2 standard. SPDY was never used to test the data in real world. It's also deprecated now.

– nagendra547
Aug 10 '17 at 7:29













That is correct. However, the HOL discussion there applies to HTTP/2 as well.

– sbordet
Aug 10 '17 at 7:48





That is correct. However, the HOL discussion there applies to HTTP/2 as well.

– sbordet
Aug 10 '17 at 7:48












2 Answers
2






active

oldest

votes


















22














HTTP Head of line blocking



Head of Line blocking in HTTP terms is often referring to the fact that each browser/client has a limited number of connections to a server and doing a new request over one of those connections has to wait for the ones before to complete before it can fire it off.



The head of line requests block the subsequent ones.



HTTP/2 solves this by introducing multiplexing so that you can issue new requests over the same connection without having to wait for the previous ones to complete.



In theory, the pipelining of HTTP/1.1 also offered a way around HOL, but it was tricky and very error-prone to implement in practice. That has made it not get widely enabled on the web even up till today.



TCP Head of line blocking



HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that package is re-transmitted and received. This HOL is being addressed with the QUIC protocol...



QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.






share|improve this answer


























  • I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

    – Tomasz P. Szynalski
    Jan 30 at 19:17











  • HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

    – Daniel Stenberg
    Jan 30 at 22:08



















12














HTTP/1 is basically a request and response protocol: the browser asks for a resource (be it a HTML page, a CSS file, an image... whatever) and then waits for the response. During this time that connection cannot do anything else - it is blocked waiting on this response.



HTTP/1 did introduce the concept of pipelining so you could send more requests while you were waiting. That should improve things as there is now no delay in sending requests, and the server can start processing them earlier. Responses must still come back in order requested so it is not a true multi-request protocol but is a good improvement (if it worked - see below). This introduced a head of line blocking (HOLB) problem on the connection: if the first request takes a long time (e.g. it needs to do a database lookup, then do some other intensive processing to create the page), then all the other requests are queued up behind it, even if they are ready to go. In fact, truth be told, HOLB was already a problem even without pipelining as the browser had to queue up requests anyway until the connection was free to send it - pipelining just made the problem more apparent on the connection level.



On top of this pipelining in HTTP/1 was never supported that well, complicated to implement and could cause security issues. So even without the HOLB issue, it still wasn't that useful.



To get around all this HTTP/1 uses multiple connections to the server (typically 6-8) so it can send requests in parallel. This takes effort and resources on both the client and server side to setup and manage. Also TCP connections are pretty inefficient for varied reasons and take time to get up to peak efficiency - by which point you've probably done the heavy lifting and no longer require multiple connections.



HTTP/2, on the other hand, has the concept of bi-directional, multiplex streams baked in from the start. I've a detailed explanation of what they are here: What does multiplexing mean in HTTP/2. This removed the blocking nature of HTTP/1 requests, introduces a much better, fully featured, fully supported version of pipelining and even allows parts of the response to be sent back intermingled with other responses. All this together solves HOLB - or more accurately prevents it even being an issue.



The one point that should be noted is that while this solves HTTP HOLB, it's still built on TCP and it has its own TCP HOLB issue which may be worse under HTTP/2 as it's a single connection! If a single TCP packet is lost, then the TCP connection must request it be resent and wait for that packet to be retransmitted successfully before it can process subsequent TCP packages - even if those packets are for other HTTP/2 streams that could, in theory, be processed during that time (like would happen under true separate connections under HTTP/1). Google is experimenting with using HTTP/2 over non-guaranteed UDP rather than guaranteed TCP in a protocol called QUIC to resolve this issue and this is in the process of being set as a web standard too (just like SPDY - initially a Google implementation - was standardised to HTTP/2).






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45583861%2fhow-does-http2-solve-head-of-line-blocking-hol-issue%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    22














    HTTP Head of line blocking



    Head of Line blocking in HTTP terms is often referring to the fact that each browser/client has a limited number of connections to a server and doing a new request over one of those connections has to wait for the ones before to complete before it can fire it off.



    The head of line requests block the subsequent ones.



    HTTP/2 solves this by introducing multiplexing so that you can issue new requests over the same connection without having to wait for the previous ones to complete.



    In theory, the pipelining of HTTP/1.1 also offered a way around HOL, but it was tricky and very error-prone to implement in practice. That has made it not get widely enabled on the web even up till today.



    TCP Head of line blocking



    HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that package is re-transmitted and received. This HOL is being addressed with the QUIC protocol...



    QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.






    share|improve this answer


























    • I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

      – Tomasz P. Szynalski
      Jan 30 at 19:17











    • HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

      – Daniel Stenberg
      Jan 30 at 22:08
















    22














    HTTP Head of line blocking



    Head of Line blocking in HTTP terms is often referring to the fact that each browser/client has a limited number of connections to a server and doing a new request over one of those connections has to wait for the ones before to complete before it can fire it off.



    The head of line requests block the subsequent ones.



    HTTP/2 solves this by introducing multiplexing so that you can issue new requests over the same connection without having to wait for the previous ones to complete.



    In theory, the pipelining of HTTP/1.1 also offered a way around HOL, but it was tricky and very error-prone to implement in practice. That has made it not get widely enabled on the web even up till today.



    TCP Head of line blocking



    HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that package is re-transmitted and received. This HOL is being addressed with the QUIC protocol...



    QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.






    share|improve this answer


























    • I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

      – Tomasz P. Szynalski
      Jan 30 at 19:17











    • HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

      – Daniel Stenberg
      Jan 30 at 22:08














    22












    22








    22







    HTTP Head of line blocking



    Head of Line blocking in HTTP terms is often referring to the fact that each browser/client has a limited number of connections to a server and doing a new request over one of those connections has to wait for the ones before to complete before it can fire it off.



    The head of line requests block the subsequent ones.



    HTTP/2 solves this by introducing multiplexing so that you can issue new requests over the same connection without having to wait for the previous ones to complete.



    In theory, the pipelining of HTTP/1.1 also offered a way around HOL, but it was tricky and very error-prone to implement in practice. That has made it not get widely enabled on the web even up till today.



    TCP Head of line blocking



    HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that package is re-transmitted and received. This HOL is being addressed with the QUIC protocol...



    QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.






    share|improve this answer















    HTTP Head of line blocking



    Head of Line blocking in HTTP terms is often referring to the fact that each browser/client has a limited number of connections to a server and doing a new request over one of those connections has to wait for the ones before to complete before it can fire it off.



    The head of line requests block the subsequent ones.



    HTTP/2 solves this by introducing multiplexing so that you can issue new requests over the same connection without having to wait for the previous ones to complete.



    In theory, the pipelining of HTTP/1.1 also offered a way around HOL, but it was tricky and very error-prone to implement in practice. That has made it not get widely enabled on the web even up till today.



    TCP Head of line blocking



    HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that package is re-transmitted and received. This HOL is being addressed with the QUIC protocol...



    QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 9 '17 at 8:57

























    answered Aug 9 '17 at 7:16









    Daniel StenbergDaniel Stenberg

    31.7k866124




    31.7k866124













    • I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

      – Tomasz P. Szynalski
      Jan 30 at 19:17











    • HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

      – Daniel Stenberg
      Jan 30 at 22:08



















    • I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

      – Tomasz P. Szynalski
      Jan 30 at 19:17











    • HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

      – Daniel Stenberg
      Jan 30 at 22:08

















    I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

    – Tomasz P. Szynalski
    Jan 30 at 19:17





    I think even with QUIC a lost packet can cause blocking. HTTP/2 header compression is based on a dynamic dictionary (repeated headers are replaced with shorthand references), which means that sometimes the server won't be able to decode the headers for Request #2 if Request #1 is lost in transmission.

    – Tomasz P. Szynalski
    Jan 30 at 19:17













    HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

    – Daniel Stenberg
    Jan 30 at 22:08





    HTTP over QUIC is called HTTP/3 and it uses QPACK, which is an adapted header compression that is similar to but not identical to HTTP/2's HPACK. The primary reason for QPACK instead of HPACK is to make sure it works with the independent streams and won't cause HOLB.

    – Daniel Stenberg
    Jan 30 at 22:08













    12














    HTTP/1 is basically a request and response protocol: the browser asks for a resource (be it a HTML page, a CSS file, an image... whatever) and then waits for the response. During this time that connection cannot do anything else - it is blocked waiting on this response.



    HTTP/1 did introduce the concept of pipelining so you could send more requests while you were waiting. That should improve things as there is now no delay in sending requests, and the server can start processing them earlier. Responses must still come back in order requested so it is not a true multi-request protocol but is a good improvement (if it worked - see below). This introduced a head of line blocking (HOLB) problem on the connection: if the first request takes a long time (e.g. it needs to do a database lookup, then do some other intensive processing to create the page), then all the other requests are queued up behind it, even if they are ready to go. In fact, truth be told, HOLB was already a problem even without pipelining as the browser had to queue up requests anyway until the connection was free to send it - pipelining just made the problem more apparent on the connection level.



    On top of this pipelining in HTTP/1 was never supported that well, complicated to implement and could cause security issues. So even without the HOLB issue, it still wasn't that useful.



    To get around all this HTTP/1 uses multiple connections to the server (typically 6-8) so it can send requests in parallel. This takes effort and resources on both the client and server side to setup and manage. Also TCP connections are pretty inefficient for varied reasons and take time to get up to peak efficiency - by which point you've probably done the heavy lifting and no longer require multiple connections.



    HTTP/2, on the other hand, has the concept of bi-directional, multiplex streams baked in from the start. I've a detailed explanation of what they are here: What does multiplexing mean in HTTP/2. This removed the blocking nature of HTTP/1 requests, introduces a much better, fully featured, fully supported version of pipelining and even allows parts of the response to be sent back intermingled with other responses. All this together solves HOLB - or more accurately prevents it even being an issue.



    The one point that should be noted is that while this solves HTTP HOLB, it's still built on TCP and it has its own TCP HOLB issue which may be worse under HTTP/2 as it's a single connection! If a single TCP packet is lost, then the TCP connection must request it be resent and wait for that packet to be retransmitted successfully before it can process subsequent TCP packages - even if those packets are for other HTTP/2 streams that could, in theory, be processed during that time (like would happen under true separate connections under HTTP/1). Google is experimenting with using HTTP/2 over non-guaranteed UDP rather than guaranteed TCP in a protocol called QUIC to resolve this issue and this is in the process of being set as a web standard too (just like SPDY - initially a Google implementation - was standardised to HTTP/2).






    share|improve this answer






























      12














      HTTP/1 is basically a request and response protocol: the browser asks for a resource (be it a HTML page, a CSS file, an image... whatever) and then waits for the response. During this time that connection cannot do anything else - it is blocked waiting on this response.



      HTTP/1 did introduce the concept of pipelining so you could send more requests while you were waiting. That should improve things as there is now no delay in sending requests, and the server can start processing them earlier. Responses must still come back in order requested so it is not a true multi-request protocol but is a good improvement (if it worked - see below). This introduced a head of line blocking (HOLB) problem on the connection: if the first request takes a long time (e.g. it needs to do a database lookup, then do some other intensive processing to create the page), then all the other requests are queued up behind it, even if they are ready to go. In fact, truth be told, HOLB was already a problem even without pipelining as the browser had to queue up requests anyway until the connection was free to send it - pipelining just made the problem more apparent on the connection level.



      On top of this pipelining in HTTP/1 was never supported that well, complicated to implement and could cause security issues. So even without the HOLB issue, it still wasn't that useful.



      To get around all this HTTP/1 uses multiple connections to the server (typically 6-8) so it can send requests in parallel. This takes effort and resources on both the client and server side to setup and manage. Also TCP connections are pretty inefficient for varied reasons and take time to get up to peak efficiency - by which point you've probably done the heavy lifting and no longer require multiple connections.



      HTTP/2, on the other hand, has the concept of bi-directional, multiplex streams baked in from the start. I've a detailed explanation of what they are here: What does multiplexing mean in HTTP/2. This removed the blocking nature of HTTP/1 requests, introduces a much better, fully featured, fully supported version of pipelining and even allows parts of the response to be sent back intermingled with other responses. All this together solves HOLB - or more accurately prevents it even being an issue.



      The one point that should be noted is that while this solves HTTP HOLB, it's still built on TCP and it has its own TCP HOLB issue which may be worse under HTTP/2 as it's a single connection! If a single TCP packet is lost, then the TCP connection must request it be resent and wait for that packet to be retransmitted successfully before it can process subsequent TCP packages - even if those packets are for other HTTP/2 streams that could, in theory, be processed during that time (like would happen under true separate connections under HTTP/1). Google is experimenting with using HTTP/2 over non-guaranteed UDP rather than guaranteed TCP in a protocol called QUIC to resolve this issue and this is in the process of being set as a web standard too (just like SPDY - initially a Google implementation - was standardised to HTTP/2).






      share|improve this answer




























        12












        12








        12







        HTTP/1 is basically a request and response protocol: the browser asks for a resource (be it a HTML page, a CSS file, an image... whatever) and then waits for the response. During this time that connection cannot do anything else - it is blocked waiting on this response.



        HTTP/1 did introduce the concept of pipelining so you could send more requests while you were waiting. That should improve things as there is now no delay in sending requests, and the server can start processing them earlier. Responses must still come back in order requested so it is not a true multi-request protocol but is a good improvement (if it worked - see below). This introduced a head of line blocking (HOLB) problem on the connection: if the first request takes a long time (e.g. it needs to do a database lookup, then do some other intensive processing to create the page), then all the other requests are queued up behind it, even if they are ready to go. In fact, truth be told, HOLB was already a problem even without pipelining as the browser had to queue up requests anyway until the connection was free to send it - pipelining just made the problem more apparent on the connection level.



        On top of this pipelining in HTTP/1 was never supported that well, complicated to implement and could cause security issues. So even without the HOLB issue, it still wasn't that useful.



        To get around all this HTTP/1 uses multiple connections to the server (typically 6-8) so it can send requests in parallel. This takes effort and resources on both the client and server side to setup and manage. Also TCP connections are pretty inefficient for varied reasons and take time to get up to peak efficiency - by which point you've probably done the heavy lifting and no longer require multiple connections.



        HTTP/2, on the other hand, has the concept of bi-directional, multiplex streams baked in from the start. I've a detailed explanation of what they are here: What does multiplexing mean in HTTP/2. This removed the blocking nature of HTTP/1 requests, introduces a much better, fully featured, fully supported version of pipelining and even allows parts of the response to be sent back intermingled with other responses. All this together solves HOLB - or more accurately prevents it even being an issue.



        The one point that should be noted is that while this solves HTTP HOLB, it's still built on TCP and it has its own TCP HOLB issue which may be worse under HTTP/2 as it's a single connection! If a single TCP packet is lost, then the TCP connection must request it be resent and wait for that packet to be retransmitted successfully before it can process subsequent TCP packages - even if those packets are for other HTTP/2 streams that could, in theory, be processed during that time (like would happen under true separate connections under HTTP/1). Google is experimenting with using HTTP/2 over non-guaranteed UDP rather than guaranteed TCP in a protocol called QUIC to resolve this issue and this is in the process of being set as a web standard too (just like SPDY - initially a Google implementation - was standardised to HTTP/2).






        share|improve this answer















        HTTP/1 is basically a request and response protocol: the browser asks for a resource (be it a HTML page, a CSS file, an image... whatever) and then waits for the response. During this time that connection cannot do anything else - it is blocked waiting on this response.



        HTTP/1 did introduce the concept of pipelining so you could send more requests while you were waiting. That should improve things as there is now no delay in sending requests, and the server can start processing them earlier. Responses must still come back in order requested so it is not a true multi-request protocol but is a good improvement (if it worked - see below). This introduced a head of line blocking (HOLB) problem on the connection: if the first request takes a long time (e.g. it needs to do a database lookup, then do some other intensive processing to create the page), then all the other requests are queued up behind it, even if they are ready to go. In fact, truth be told, HOLB was already a problem even without pipelining as the browser had to queue up requests anyway until the connection was free to send it - pipelining just made the problem more apparent on the connection level.



        On top of this pipelining in HTTP/1 was never supported that well, complicated to implement and could cause security issues. So even without the HOLB issue, it still wasn't that useful.



        To get around all this HTTP/1 uses multiple connections to the server (typically 6-8) so it can send requests in parallel. This takes effort and resources on both the client and server side to setup and manage. Also TCP connections are pretty inefficient for varied reasons and take time to get up to peak efficiency - by which point you've probably done the heavy lifting and no longer require multiple connections.



        HTTP/2, on the other hand, has the concept of bi-directional, multiplex streams baked in from the start. I've a detailed explanation of what they are here: What does multiplexing mean in HTTP/2. This removed the blocking nature of HTTP/1 requests, introduces a much better, fully featured, fully supported version of pipelining and even allows parts of the response to be sent back intermingled with other responses. All this together solves HOLB - or more accurately prevents it even being an issue.



        The one point that should be noted is that while this solves HTTP HOLB, it's still built on TCP and it has its own TCP HOLB issue which may be worse under HTTP/2 as it's a single connection! If a single TCP packet is lost, then the TCP connection must request it be resent and wait for that packet to be retransmitted successfully before it can process subsequent TCP packages - even if those packets are for other HTTP/2 streams that could, in theory, be processed during that time (like would happen under true separate connections under HTTP/1). Google is experimenting with using HTTP/2 over non-guaranteed UDP rather than guaranteed TCP in a protocol called QUIC to resolve this issue and this is in the process of being set as a web standard too (just like SPDY - initially a Google implementation - was standardised to HTTP/2).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 3 at 1:26

























        answered Aug 9 '17 at 7:32









        Barry PollardBarry Pollard

        17.4k32750




        17.4k32750






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45583861%2fhow-does-http2-solve-head-of-line-blocking-hol-issue%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mossoró

            Error while reading .h5 file using the rhdf5 package in R

            Pushsharp Apns notification error: 'InvalidToken'