Exploring http2 (Part 1): Overview

Jeevan D C
3 min readJun 15, 2018

--

source: https://css-tricks.com/

Let’s talk about What, why, when and how of http2

The complete code can be found on github.

Part 1: Overview
Part 2: Exploring with node-http2 core and hapijs

What is http2?

http2 is the latest update after http1.1 which is being used since 1999.

The http2 protocol is focused on performance; specifically, end-user perceived latency, network and server resource usage. (Read about the specifications here)

Why http2?

In other words what’s wrong with http1.1

Loading a web page is resource intensive, as HTTP/1.1 only allows one outstanding request per TCP connection. The web needed an update which brings in advancements in efficiency, security and speed.

How does http2 solve performance problems?

Improvements http2 brings in:

  • Single Connection: Only one connection to the server is used to load a website and that connection remains open as long as the website is open. This reduces the number of round trips needed to set up multiple TCP connections. (more info here)
  • Multiplexing: Multiple requests are allowed at the same time, on the same connection. Previously, with HTTP/1.1, each transfer would have to wait for other transfers to complete. (more info here)
  • Server Push: Additional resources can be sent to a client for future use. (more info here)
  • Prioritization: Requests are assigned dependency levels that the server can use to deliver higher priority resources faster. (more info here)
  • Binary: Makes HTTP/2 easier for server to parse, more compact and less error-prone. No additional time is wasted translating information from text to binary. (more info here)
  • Header Compression: HTTP/2 uses HPACK compressions, which reduces overhead. Many headers are sent with the same values in every request in HTTP/1.1. (more info here)

When can we start using http2?

Now!

Here is the timeline,

source: https://www.polyglotdeveloper.com/

Yes, from 1999 to today we(most) are using same good old http1.1; 15 years!

How to start using http2?

Here is the list of library implementations for http2 in various languages.

According to Can I Use, ~83% browsers online support http2 already

See it in action, http1.1 vs http2 (network throttled: fast 3g)

http1.1 (left) vs http2 (right); let’s build this in next section

In the next part let’s build a simple server with http2 support; with http1.1 backward compatibility; step by step with http2-node core and hapijs.

Part 1: Overview
Part 2: Exploring with node-http2 core and hapijs

The complete code can be found on github.

If you found this story useful, please support it by clapping 👏

--

--

Jeevan D C
Jeevan D C

No responses yet