Is HTTP/2 really worth it?
Tags: devops, performance, nginx, gatling
Published: 2018-11-13 01:52:48

---
title: Is HTTP/2 really worth it?
published: true
description: Just how much performance does HTTP2 offer? Like many other things in technology; it depends. Rea on to learn the benefits and pitfalls of using HTTP/2.
tags: #devops, #performance, #nginx, #gatling
cover_image: https://blog.davidjeddy.com/wp-content/uploads/2018/11/http_http2_results_1-930x620.png
---

<!-- wp:paragraph -->
<p>TL;DR: Yes, but...</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Background</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>HTTP has been the protocol the web has been built on since 1991 when version 0.9 was released. It has been the back bone technology nearly every network communicating device relies on. And for 24 years HTTP remained largely unchanged. But as all things time marches forward and so does technology. In 2015 HTTP2 was released to the world. With encrypting as a mandatory part of the technology it bring security; with multiplexing it brings increased response rate to resource requests, and with a push ability the server can respond with resources before the client even requests them. All this and more combine to make a very impressive iteration of the protocol.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1149} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/HP_revised_8-4_Illo_1.png" alt="" class="wp-image-1149"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Configuration</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Using a very basic LEMP stack I setup a basic web server, then abused it with 10 requests per second over 5 minutes. This provides a baseline of the performance to expect from a specific set of hardware. Then I configured a SSL certification (as required for HTTP/2). Followed by a minor edit of the Nginx configuration blasted the same server with the same load. The result was a 1 for 1 comparison between HTTP 1.1 and version 2. <a href="https://github.com/davidjeddy/how_effective_is_http2">The repo can be reviews over on GitHub</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1155} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/htop.png" alt="" class="wp-image-1155"/><figcaption>10 users per second for 5 minutes, poor little web server.</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>The Good, The Bad, The Ugly</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->
<h4>The Good</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Performance was measurably increased. With multiplexing the many images where responded to in parallel instead of serial responses. Additionally the average response rate looks to have decreased by about 10%</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1156} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/http_http2_results_1.png" alt="" class="wp-image-1156"/><figcaption>More responses, faster. Not as much as I thought, but still an improvement.</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 id="mce_12">The Bad</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>This is not really a bad thing, but HTTP/2 requires SSL and the associated configuration. Year ago an SSL certification use to be expensive. This is not so much an issue any longer thanks to <a href="https://letsencrypt.org/">Lets Encrypt</a>. I am not sure I would use Lets Encrypt in a large scale production environment but it gets the job done. Configuration take understand Linux operation and Nginx configuration.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1157} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/http_http2_results_2.png" alt="" class="wp-image-1157"/><figcaption>OH, look at that. Smoother handling of results, and faster responses.</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 id="mce_12">The Ugly</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The performance gain was not as much as I had hoped. The main reason for this is the handling of the SSL. It does require CPU overhead to validate and process the traffic encryption. If you want to get fancy it is possible to off-load the SSL handling to a load balancer, thus leading the server to only process the request.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1158} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/http_http2_results_3.png" alt="" class="wp-image-1158"/><figcaption>HTTP only: over 100 resources failing. HTTP/2 under 100. Nice.</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Additional Resources</h2>
<!-- /wp:heading -->

<!-- wp:list -->
<ul><li><a href="https://developers.google.com/web/fundamentals/performance/http2/">Google Web Fundamentals Introduction to HTTP/2</a></li><li><a href="https://en.wikipedia.org/wiki/HTTP/2">https://en.wikipedia.org/wiki/HTTP/2</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-18-04">https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-18-04</a></li><li><a href="https://http2.akamai.com/">https://http2.akamai.com/</a></li></ul>
<!-- /wp:list -->

<!-- wp:image {"id":1150} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/11/HP_revised_8-4_Illo_2.png" alt="" class="wp-image-1150"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>All in all HTTP/2 provides a decrease in response time, enforces encryption and is not terrible difficult to enable. Using the more advanced features (suc as push) and a caching system HTTP/2 is an amazing improvement to a corner stop internet technology.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Extra images sourced from&nbsp;<a href="https://chadhagen.com/">https://chadhagen.com/</a> . Go help them out, Chad's work is amazing.)</p>
<!-- /wp:paragraph -->