# ignites, HTTP2 in 5 Minutes

- Speaker: Ben Maraney
- Event: Reversim Summit 2015
- YouTube: https://www.youtube.com/watch?v=fJ0C4zN5uOQ
- Model: gemini-3.5-flash-lite

> Machine transcript, may contain errors.

---

[00:08] Hi, I'm Ben, I'm a software engineer at Klarna. I'm going to talk to you about how HTTP11 made the web slow and hacky. Um, what HTTP2 is going to do to change that and what it means for us as web developers. So the reason I'm talking to you about this today is that just a few weeks ago, the internet engineering steering group signed off on the HTTP2 standard. Browser support is here in Firefox. It's pretty much here in Chrome. It's coming soon in Internet Explorer and in Safari. So now's the time we need to think about what it means for us. Let's talk about the problem it's trying to solve. Websites keep getting bigger. There's more images, more JavaScript, more CSS, more things to download. And in a way that's no big deal because the bandwidth available to end consumers has been growing exponentially for the last 30 years. But what hasn't improved is round trip time or ping time, the time it takes to get a message from my computer to a server and back again. In fact, if you look at times from Stanford to MIT, they've dropped only 2 milliseconds in 20 years. We can't expect any significant gains there because it's in part limited by the speed of light. So let's talk about HTTP11. What happens is we establish a connection to the server, a TCP handshake, round trip there and back and request a file, and then we get it sent to us. That's another round trip.

[01:19] So, if you imagine a typical site with 100 objects on it, that's two round trips per object, 80 milliseconds, let's say the whole thing takes 16 seconds. Clearly it's far too slow. So, one of the things we do to improve that is that we reuse our connections, using something called HTTP persistent. So, we do the handshake, request a file, get it back, request another file, get it back. And so we can effectively halve the number of round trips we need to make. So, with 100 objects, one round trip, 80 milliseconds, 8 seconds, still way, way, way too slow. So that's led to a whole series of hacks designed to get around that problem. One of those is that modern browsers will use multiple connections to the same host, Chrome will use up to six, and then web developers tend to split their assets across different hosts, that's called sharding. So here you can see YouTube hosting images on four different hosts. That means they can about 24 simultaneous downloads, but that sucks. It's a hack. It's harsh on the browser, on the network, and on the server. It's just not what TCP is optimized for. TCP is much better for long-lived connections between a client and a server.

[02:23] Another thing we do is we combine images together. So here, YouTube combines 250 images into one file, 40 pages of CSS, 80 pages of JavaScript, and it kind of works, but it's really inconvenient, and it breaks caching. If I want to change just one of those images just very slightly, everyone has to download the whole file again. The same thing if I want to tweak the JavaScript or the CSS. So, let's start talking about HTTP2. The good news is that as far as your web app's concerned, nothing changed. The methods, the headers, the cookies, all the same. The only thing that changes the way in which the web server sends the information down the wire to your web browser in a new binary format. One of the cool things that format allows for is multiplexing. That means that I can request a whole bunch of files and receive those files at the same time. So, let's have a look at what impact this one optimization has. We'll look at the YouTube homepage. What happens with HTTP11 is that I start requesting some images, I ran out of connections pretty quickly, so I have to wait for those to finish downloading before I request the next batch. And that happens again and again and again. So, the last image that I request actually gets requested more than half a second after the page starts to load. Whereas with HTTP2, I request all of those images and start receiving them at the same time, which gives me an improvement of about 20% on a page which is still essentially optimized for HTTP11.

[03:47] So let's talk about some of HTTP2's more advanced features that will get us better improvements than this. One problem we have is that if to know I need some images, I probably need to load some CSS. And to know I need that CSS, I probably need to load the HTML, which is three round trips. So HTTP solution to HTTP2 solution is called server push. A well configured server can recognize that if I request this file, well, I probably want these these other files as well. And it can start sending those to me before I even ask for them, and they'll go straight onto my browser's cache. So in principle, I can request one file and I get the whole site sent to me in one go. Other cool things it does is priority things I don't have time to get into now, really, but prioritizing the files it's sending to me, resets on files I don't need anymore, flow control and header compression. Those are really interesting subjects, I recommend reading up on them. If you're interested, a great place to start is a PDF called HTTP2 explained by a guy called Daniel Stenberg. He was involved in sending HTTP2 standard. Just Google for it, it's the first result.

[04:47] So what's it mean for us? Well, the first thing is that a lot of those those hacks will stop being relevant and they'll be replaced with a whole new set of best practices which take advantage of HTTP2's more advanced features. So my advice for you is be involved in discussions on how we can take advantage of HTTP2 and don't be surprised when things change. Thanks for listening.
