As more and more demand is being placed on web applications in terms of overall responsiveness while providing a rich user experience, the burden also increases 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?
Why do websites use HTTP/2?
As of December 2018, over 32% 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?
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
JMeter is arguably the most popular open source load testing tool on the planet. It is well regarded for it’s ability to test web applications of all shapes and sizes. Unsurprisingly, JMeter is one of the tools that shines in testing the emerging world of HTTP/2. If you’ve never tested with JMeter before, getting started with a basic test is fairly straightforward:
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 so 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:
- HTTP2 Request Defaults
- HTTP2 Request
- Simple Data Writer HTTP2
- 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 as we did locally 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.
An example 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 & 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:
- Google search rankings favour sites using HTTP/2
- Backwards compatible with HTTP/1.1
- Browser agnostic
- 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!