HTTP/2 vs HTTP 1.x

Let’s take a look at the key differences compared to HTTP 1.x and what issue each improvement is addressing:

  • HTTP/2 is a binary protocol where HTTP 1.x is textual. Binary protocols are more efficient to parse because there is only one code path where HTTP 1.x defines 4 different ways to parse a message. Binary protocols are also more space efficient on the wire. In return, it is more difficult for humans to deal with them, as they are not human-readable. A tradeoff.
  • HTTP/2 is multiplexed to tackle a known limitation in networking known as head-of-line blocking (HOL Blocking). This problem can occur with HTTP 1.1 when multiple requests are issued on a single TCP connection (aka HTTP pipelining). As the entire connection is ordered and blocking (FIFO), a slow request can hold up the connection, slowing down all subsequent requests. Multiplexing definitively solve this problem by allowing several request and response to fly on the wire at the same time.
  • HTTP/2 uses header compression to reduce overhead. Typical header sizes of 1KB are common mainly because of the cookies that we all have to accept for a smooth user experience. Transferring 1KB can take several network round trips just to exchange headers, and those headers are being re-sent every time because of the stateless nature of HTTP 1.x. The TCP Slow-start makes the problem even worse by limiting the number of packets that can be sent during the first round trips until TCP effectively finishes to probe the network to figure out the available capacity and properly adapt its congestion window. In this context, compressing headers significantly limits the number of required round trips.
  • HTTP/2 Server Push allows servers to proactively send responses into client caches. In a typical HTTP 1.x workflow, the browser requests a page, the server sends the HTML in the response, and then needs to wait for the browser to parse the response and issue additional requests to fetch the additional embedded assets (JavaScript, CSS, etc.). Server push allows the server to speculatively start sending resources to the client. Here, the browser does not have to parse the HTML page and find out which other resources to load; instead the server can start sending them immediately.


要查看或添加评论,请登录

Amit Rai的更多文章

  • Difference between array and arraylist #java

    Difference between array and arraylist #java

    I. Size: Array in Java is fixed in size.

  • Java Stream API for Bulk Data Operations on Collections

    Java Stream API for Bulk Data Operations on Collections

    A new java.util.

  • Nashorn

    Nashorn

    Nashorn: A Next-Generation JavaScript Engine for the JVM by Julien Ponge Scenarios for using Oracle Nashorn as a…

  • CLUSTER

    CLUSTER

    A single instance of Node.js runs in a single thread.

  • Parallel Operations

    Parallel Operations

    With the addition of Lambda expressions to arrays operations, Java introduced a key concept into the language of…

  • RxJS

    RxJS

    What is RxJS? RxJS or Reactive Extensions for JavaScript is a library for transforming, composing, and querying streams…

  • Concurrent Accumulators

    Concurrent Accumulators

    One of the most common scenarios in concurrent programming is updating of numeric counters accessed by multiple…

  • Garbage-First Garbage Collector

    Garbage-First Garbage Collector

    The Garbage-First (G1) garbage collector is a server-style garbage collector, targeted for multiprocessor machines with…

  • Exception Propagation

    Exception Propagation

    After a method throws an exception, the runtime system searches the call stack for a method that contains a block of…

  • Microbenchmarks

    Microbenchmarks

    Microbenchmarks are coming The Java Microbenchmarking Harness (JMH) by Alexey Shipilev is taking the next step in its…

社区洞察

其他会员也浏览了