HTTP/2: The Future of the Internet

What is HTTP/2?

After more than 15 years, the Hypertext Transfer Protocol (HTTP) received a long-overdue upgrade. HTTP/2 is largely based on Google’s experimental SPDY protocol, which was first announced in November 2009 as an internal project to increase the speed of the web.

HTTP/2 is a replacement for how HTTP is expressed “on the wire.” It is not a ground-up rewrite of the protocol. HTTP methods, status codes and semantics are the same, and it should be possible to use the same APIs as HTTP/1.x (possibly with some small additions) to represent the protocol.

The focus of the protocol is on performance; specifically, end-user perceived latency, network and server resource usage. One major goal is to allow the use of a single connection from browsers to a Web site.

Benefits of HTTP/2

The main focus of both SPDY and HTTP/2 is performance, especially latency as perceived by the end-user while using a browser, with a secondary focus on network and server resource usage. One large benefit of HTTP/2 is the ability to use a single TCP connection from a browser to a website.

HTTP/2 Architecture
Its many benefits include:
  • Multiplexing and concurrency: HTTP/2 supports multiplexing several streams over a single connection. This means that a client can send multiple requests on the same connection, and the server can respond in whatever order the responses become available.
  • Stream dependencies: the client can indicate to the server which of the resources are more important
    than the others
  • Header compression: HTTP requests and responses generally include a large number of redundant headers. HTTP/2 uses HPACK header compression to greatly compress headers.
  • Server push: Server push allows a server to send additional cacheable resources to the client that the client has not explicitly asked for. The allows the server to anticipate the resources the client will request next and send them eagerly, which saves a round trip.

You will not need to change your websites or applications to ensure they continue to work properly. Not only will your application code and HTTP APIs continue to work uninterrupted, but your application will also likely perform better and consume fewer resources on both client and server.

As it becomes more prevalent, organizations looking to benefit from the performance and security features of HTTP/2 should start thinking about how they are invested to fully capitalize on these new capabilities. Such considerations include:

  • Encrypting: Applications running over HTTP/2 are likely to experience improvements in performance over secure connections. This is an important consideration for companies contemplating the move to TLS.
  • Optimizing the TCP layer: Applications should be designed with a TCP layer implemented to account for the switch from multiple TCP connections to a single long-lived one, especially when adjusting the congestion window in response to packet loss.
  • Undoing HTTP/1.1 best practices: Many “best practices” associated with applications delivered over HTTP/1.1 (such as domain sharding, image spriting, resource in-lining and concatenation) are not only unnecessary when delivering over HTTP/2, and in some cases may actually cause sub-optimizations.
  • Deciding what and when to push: Applications designed to take advantage of the new server push capabilities in HTTP/2 must be carefully designed to balance performance and utility.

How Should Developers Prepare?

HTTP/2 requires developers to unlearn a lot of tricks they employed to overcome the limitations of HTTP. Design hacks developed to make HTTP run faster, such as CSS sprites and inlining, can create issues when used with HTTP/2.

In addition, since HTTP/2 is binary, some network inspection/management techniques and tools that you’ve relied on in the past will no longer be useful. For example, plain-text debugging is no longer an option. Therefore monitoring tools will need upgrading as soon as HTTP/2-friendly updates are rolled out.

Web server frameworks will also have to be updated to support HTTP/2, although some, like Yesod and Express, are already compliant and may simply require that an ops specialist enable the protocol.

Conclusion

We all know that faster sites help improve search engine rankings, but faster sites also offer better user experiences. Faster sites engage your users longer, and promote sharing further sharing and linking. HTTP/2 is an amazing leap forward that can help improve the performance and user experience of your website. However, HTTP/2 is not a silver bullet. Optimizations like losslessly optimizing your website’s images can have a big effect on your site’s performance and will still be needed. In short, while you should add HTTP/2 support to your website, make sure you are doing other optimizations and following performance best practices to ensure the best possible user experience.