HTTP2: the good, the bad, the ugly

HTTP2: the good, the bad, the ugly

I spent last few weeks investigating on HTTP2, the successor of HTTP1.1 and I’d like to share my findings and thoughts in this post.

Let’s start saying that if the question you have in mind at this point is: “Can I really use it today, not only for experiments but also in production?”

?My answer would be: “YES, you can!”

First of all, I’d like to share with you the browsers implementation status for this protocol

As you can see from the screenshot taken from caniuse.com it’s definitely well supported on the latest version of the major browsers with some caveats obviously.

If you are not convinced yet, please check this website with one of the browsers that currently supports HTTP2 and look how fast to load is!

I’d suggest to install the HTTP2 indicator Chrome extension to discover how many web apps or online services are using this protocol:

Not yet convince?! OK let’s move to a deeper analysis then!

HTTP2 is a binary protocol with a multiplexing requests method implemented, that means all the browser requests will be handled asynchronously.

This massive change will increase drastically the performance of your application.

Considering at the moment a browser can download simultaneously a maximum of 5 resources per domain (let’s avoid talking about “resource sharding” for now), with HTTP2 we will be able to request all the resources and render them when the browser will accomplish their download, check this demo made with Go Lang for a proper comparison between the 2 protocols and check also the Network panel in the Chrome Dev Tools or Firefox dev tools in order to understand how the 2 protocols differ.

The Good

HTTP2 has really few rules in order to be implemented:

  • it works ONLY with https protocol (therefore you need a valid SSL certificate)
  • it’s backward compatible, so if a browser or a device where your application is running, don’t support HTTP2 it will fall back to HTTP1.1
  • it comes with great performance improvements out-of-the-box
  • it doesn’t require to do anything on the client side but on the server side for a basic implementation
  • few new interesting features will allow to speed up the load of your web project in a way that is not even imaginable with HTTP1.1 implementation

Despite the short list, HTTP2 is bringing a substantial change to the internet ecosystem.

One of my favourite feature is the server PUSH where a server can pass a link header specifying what the browser should download in advance before starting to parse entirely the HTML document.

In this case, we can educate the browser to download several resources like images, css or even javascript files before the engine recognise them inside the DOM, providing a better user experience to our web apps and/or games.

The Bad

There is still plenty of works to do in order to have a great penetration of this protocol, few specs are still on-going (read the next paragraph: the ugly) and probably it will take quite few months before we will see a lot of services moving to this new protocol.

A part from the high-level overview of the downsides, let’s look what will change on the technical side.

Considering that HTTP2 is not restrict the amount of requests a browser is doing in order to download resources few techniques for optimising our websites will need to be reviewed or even removed from our pipeline.

Delivering all the application inside a unique javascript file won’t have any benefit with HTTP2, so we need to move our logic downloading only what we need when we need it.

Knowing that downloading large files won’t be a problem we could use sprites instead of several small images to handle the icons of our website.

Probably the different tools like Grunt, Gulp or Webpack will need to review their strategies or update their plugin in order to provide real value to this new project pipeline.

The Ugly

Google Chrome protocol implementation!

Chrome is my favorite browser and I use it extensively, in particular, when I need to debug a specific script or I need to gather metrics from a specific behavior of a web app.

At the moment it’s the only browser that requires HTTP2 server negotiation via ALPN (Application-Layer Protocol Negotiation) that basically is an extension allowing the application layer to negotiate which protocol will be used within the TLS connection.

Considering that OpenSSL integrates ALPN only from version 1.0.2, we won’t be able to enable HTTP2 protocol support for Chrome (from build 51 and above) if we don’t configure our server correctly.

For instance, on Linux OS, only Ubuntu from version 16.04 has that OpenSSL version installed by default, for all the other major Linux version you will either install the newer version manually or you’ll need to wait for the next major OS release.

I’d suggest reading carefully the article that describes this “issue” on ngnix blog before you start to configure your server for Chrome.

Wrap up

HTTP2 is not perfect and probably is not supported as it should be but, definitely, could improve (drastically in certain cases) your web project performance.

A lot of “big players” are already using HTTP2 protocols in production (Instagram, Twitter or Facebook for instance) and the results are remarkable.

Why not starting catching up with the future today?


Goffredo Marocchi

Development Manager at Bally’s Interactive ?/Android

8 年

Really nice and informative article, but not surprising given the author :). I think this link really helps sell it visually without going into advanced territory: https://http2.golang.org/gophertiles?latency=1000

Enrico Pesce

Cloud Solution Engineer | Driving Customers and ISV Growth Through Cutting-Edge Oracle Tech Solutions | Transforming Challenges into Opportunities

8 年

Great article!

Aysun Akarsu

Data Scientist | Lifelong Learner | Founder | Speaker | Dual Citizen France & Turkey

8 年

At "the bad" part I would add Googlebot's lack of HTTP2 support as well as unavailability of some HTTP2's outstanding features like "server push" at NGINX's last versions although these versions support HTTP2. It is good that you mentioned about the top websites HTTP2 support becouse I have written an article about HTTP2 and the top websites which shows that 39% of the 100 top websites in the world support HTTP2. Please find my article at https://www.dhirubhai.net/pulse/http2-top-websites-aysun-akarsu

Petr Stojan

ICT technology consultant, Senior Project / Delivery Manager and Cyber Security Program Manager

8 年

I've spent few night with HTTP2 testing as well and I have very similar result. Google Chrome protocol implementation is nightmare. Yes, it is much more faster but still I'm not impressed. BTW: Very good article.

回复

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

Luca Mezzalira的更多文章

  • The data recovery challenge in the cloud era

    The data recovery challenge in the cloud era

    In today’s digital-first world, businesses are generating and storing data at an unprecedented scale. With the rise of…

    1 条评论
  • Instant recovery strategies for S3 and DynamoDB in the AI era

    Instant recovery strategies for S3 and DynamoDB in the AI era

    A few weeks ago, I had the opportunity to attend the SHIFT conference organized by Commvault, and it was quite an…

    1 条评论
  • How Micro-Frontends are reshaping Modern Web Architecture

    How Micro-Frontends are reshaping Modern Web Architecture

    Are you frustrated with slow deployment cycles, tightly coupled dependencies, and the cumbersome nature of managing…

    5 条评论
  • How to Document Software Architecture: Techniques and Best Practices

    How to Document Software Architecture: Techniques and Best Practices

    In software development, documentation is often overlooked in favor of coding. However, documenting software…

    32 条评论
  • Unlocking the Power of Your Second Brain

    Unlocking the Power of Your Second Brain

    Ever feel like you’re drowning in information and struggling to keep up? You’re not alone. The secret to thriving in…

    5 条评论
  • My Personal productivity hacks with Apple Devices

    My Personal productivity hacks with Apple Devices

    Smartphones, tablets, smartwatches — all are competing to grab our attention. The problem is that when it happens, it…

    3 条评论
  • Micro-frontends, the future of Frontend architectures

    Micro-frontends, the future of Frontend architectures

    In the past 30 months, I had the opportunity to work on one of the most challenging architectures I’ve ever designed in…

    2 条评论
  • The first book on Front-end Reactive Architectures

    The first book on Front-end Reactive Architectures

    When I proposed this book the first time a couple of years ago, Reactive Programming wasn’t “a thing” yet in the…

    5 条评论
  • The art of coding

    The art of coding

    The art of coding Today I spent few hours in my favourite London museum: The Design Museum. I went to the main…

    1 条评论
  • Benchmarking Falcor.js

    Benchmarking Falcor.js

    In the past few weeks I was figuring out how to solve a problem of a chatty communication between client and server…

社区洞察

其他会员也浏览了