Testing HTTP/2 with JMeter

In this tutorial, we'll cover everything from testing and evaluating the performance of HTTP/2.

JMeter Tutorial: HTTP2 Test


As more and more demand is being placed on web applications in terms of overall responsiveness while providing a rich user experience - this requirement is also placing a huge burden on to the existing HTTP/1.1 protocol that we all know and love.

In this tutorial, we will answer all of your questions about HTTP/2 Testing:

  • What is HTTP/2?
  • Why Websites use HTTP/2?
  • How Much Faster is HTTP/2 than HTTP/1.1?
  • How to set up JMeter to test HTTP/2?
  • How to write a simple JMeter test for HTTP/2?
  • How to upload your HTTP/2 JMeter test to Flood for scaled testing?
  • Is it worth moving to HTTP/2?

What is HTTP/2?

HTTP/2 is the next generation protocol based on a Google project called SPDY to provide higher levels of performance to web applications.

Why websites use HTTP/2?

As of March 2018, almost 25% of the top 10 million websites support it - so it is becoming increasingly common. Along with adoption comes the need to be able to validate an application's performance and reliability built upon the technology.

HTTP/2 contains a number of improvements over HTTP/1.1 - namely:

  • Data compression of HTTP headers
  • HTTP/2 Server Push capability
  • Request Pipelining
  • Fixing some known issues with HTTP/1.1
  • Multiplexing multiple requests over a single TCP connection

How Much Faster is HTTP/1.1 vs. HTTP/2.2?

Take a look at the differences in load times for an image made up of smaller image ‘tiles’ being downloaded using the two protocol versions:

How to Test HTTP/2 with JMeter


Step 1: Setting up the HTTP/2 Sampler in JMeter

In this guide - we'll be using JMeter to generate HTTP/2 requests against an HTTP/2 enabled target application. We'll also be using the HTTP/2 Sampler which doesn't come included with the default JMeter installation and we'll have to add it in.

First of all it helps substantially to have the JMeter plugins manager installed ). Following the instructions to install JMeter plugins manager will allow you to easily install any available add-in as well as any dependencies that are required.


From the JMeter plugins manager, search for the HTTP/2 plugin, select HTTP/2 Sampler from the list and click on the Apply Changes and Restart JMeter. You will now have the HTTP/2 Sampler available to be included in your script.

Note: this only installs the necessary HTTP/2 libraries locally.  We'll cover how to get these uploaded into Flood further into this guide.

 

Step 2: Setting up a simple HTTP/2 JMeter test plan

In order to properly test HTTP/2 endpoints - the JMeter test plan must contain updated plugins specifically for the HTTP/2 protocol. These add-ins include modified versions of the default HTTP/1.1 plugins - which are:

  1. HTTP2 Request Defaults
  2. HTTP2 Request
  3. Simple Data Writer HTTP2
  4. View Results Tree HTTP2

These need to be used in place of their default HTTP/1.1 counterparts when testing HTTP/2 target sites.

Here's an example of a simple test plan which essentially runs a single thread group with a single asynchronous HTTP/2 request:


Step 3: Scaling your HTTP/2 JMeter Test with Flood

Running HTTP/2 tests through Flood will require that you upload these same libraries via the plugins manager. Since the HTTP/2 plugins use an implementation of Jetty - there are a number of Jetty libraries that JMeter needs to run successfully and they need to be uploaded to Flood alongside the actual script.

A fully functional zip file containing all necessary jar libraries to run HTTP/2 tests through Flood for JMeter 3.3 has the following directory structure:

The file located in the lib/ext path called alpn-boot-8.1.9v20160720.jar is the specific Jetty ALPN library file that is required to be uploaded to Flood so that JMeter can successfully send and receive HTTP/2 requests via Jetty over TLS.

You will need to download the ALPN library which is specific to your exact JVM version. The above file is the correct one to use with Flood with JMeter 3.3. 

A list of ALPN library file version and the equivalent JVM version to be used is available here: https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html#alpn-versions

You will need to specify the path to this file via the Java classpath in the Advanced Parameters section of setting up a new flood as follows:

This will ensure that Flood’s JMeter image is able to find the library. This must be done in order to successfully run a HTTP/2 test.

As mentioned previously - you will need to upload the zip file along with your script file as follows:

In our example HTTP/2 script we have both HTTP/1.1 & HTTP/2 requests for the same pages & resources. This is intended in order to see the performance difference between the two versions of protocols in terms of response times in the same test.


Running the test even with only a handful of users shows a significant difference in response times between the two protocol versions. As you can see in the screenshot below every single HTTP/2 request is better performing (shown as lower response times) than it’s HTTP/1.1 equivalent.

So is it worth migrating my site to HTTP/2?


In one word - Absolutely! 


Not only will your site respond and perform better for your customers but there are additional benefits by using it as part of your web application stack, namely:


  1. Google search rankings favour sites using HTTP/2
  2. Backwards compatible with HTTP/1.1
  3. Browser agnostic
  4. Reduced latency


Using JMeter to validate your HTTP/2 enabled site’s performance is quite an involved task however it is very beneficial to understanding how your site will respond to periods of increased levels of traffic. It will also enable you to utilize the latest technologies while ensuring your end users observe a fast and reliable experience.


If you would like to run your own HTTP/2 JMeter tests in Flood, you can sign up for a free trial to get started testing now!



Start load testing now

It only takes 30 seconds to create an account, and get access to our free-tier to begin load testing without any risk.