HTTP/2 Characteristics and Performance Evaluation

Zeynep Sanliturk
5 min readNov 26, 2017

--

In my previous blog post, I introduced HTTP/2 to you and then I mentioned that why we should like HTTP/2, what features HTTP/2 has.

In this section HTTP/1.1 and HTTP/2 performance comparison will be done. For this, experiments will be done by creating servers and clients in different zone on Digitalocean cloud provider. The test setup will consist of an HTTP client, an HTTP server and the network between them. The schematic diagram of the test setup is shown below. In both server and client machines, the 16.04 server version of the Ubuntu Linux distribution will be preferred. The client and server machines must have 1 core processor and 512 MB of memory.

The scenario is as follows:

  • The HTTP client requests a sample web page from the HTTP server. HTTP/2 and HTTP/1.1 clients in the cloud are located in New York, USA and the server is located in Frankfurt, Germany.
  • An open source Apache web server will be preferred on the server machine. The Apache module mod_http2, which provides HTTP/2 support, can be used to compare the performance of HTTP/1.1 and HTTP/2 protocols.
  • The sample web page will be set to an average web page size and component properties of today. The average web page for 2016 data is 2.4 MB.
  • The minimum number of packets per stream is continuously increasing. For this reason, our measurements use 40 packets per stream, so 40 simultaneous clients will make requests.

NOTE: HTTP/2 requires TLS encryption, although not required in the declaration, because browsers such as Firefox, Chrome and Internet Explorer only support HTTP/2 over HTTPS (Secure HTTP).

For this reason, you can set the SSL settings for the server machine by following the steps here.

Then run the following line of code on your server machine.

$ a2enmod http2

You will see the following output:

ERROR: Module http2 does not exist!

Here you should provide http2 support with mod_http2. For this, in /etc/apache2/sites-available/default-ssl.conf, paste the following line of code under the ‘DocumentRoot’.

Protocols h2 http/1.1

Additionally, set a good logging level for the http2 module.

LoadModule http2_module modules/mod_http2.so

<IfModule http2_module>
LogLevel http2:info
</IfModule>

Save the file and restart the apache2 service.

When you start your server and look in the error log, you should see one line like:

[timestamp] [http2:info] [pid XXXXX:tid numbers] 
mod_http2 (v1.0.0, nghttp2 1.3.4), initializing...

Run the line of code again.

$ a2enmod http2

You should see the output below.

Module http2 already enabled

If you have curl on your system maintained by Daniel Stenberg, there is an easy way to check its http/2 support:

$ curl -V

The output should be like this:

curl 7.45.0 (x86_64-apple-darwin15.0.0) libcurl/7.45.0 OpenSSL/1.0.2d zlib/1.2.8 nghttp2/1.3.4
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets

Congratulations, your website now supports http2, server machine is completely done!

Here is an example apache configuration file:

NOTE: You can visit my github repository for a server machine that you can use as an example and for the code that I share below.

The client machine will be configured to send HTTP/2 and HTTP/1.1 requests. The h2load module of nghttp2, the benchmarking tool, will be used. You can look at the link to the h2load module and nghttp2 tool. We will install the nghttp2 tool on the client machines with the bash script in GitHub below.

The client machine will be configured to send HTTP/2 and HTTP/1.1 requests. The h2load module of nghttp2, the benchmarking tool, will be used. You can look at the link to the h2load module and nghttp2 tool. We will install the nghttp2 tool on the client machines with the bash script in GitHub below.

Here we need to know two commands to accomplish the scenario. First one, there is a sample HTTP / 2 request below, with 40 different clients on the Google homepage and 100 requesting usage examples and check the result.

To make sure that the module is successfully uploaded, let’s test it by sending the following command to google HTTP/2 request. The output will look like the picture below.

Now let’s do the same test by submitting HTTP/1.1 request. So let’s use the command below.

If we do not get a “failed” or an “errored” on the output, then everything is fine.

Second one, deterioration values such as network latency and packet loss are produced by open source tcng. An exemplary usage with a 50 ms delay and a 0.3% packet loss rate is shown below.

tc qdisc add dev eth0 root netem delay 50ms loss 0.3%

The download time of the generated test website will be measured. The download period is the interval between the first request of the client and the last response of the server. Each measurement operation will be repeated 20 times. A parametric shell script written for the measurement operations will be run on the client machines and the measurement results will be taken. These two commands are mentioned in the following shell program to provide the necessary conditions.

Run the command by entering the IP address of your server into $1. Do not forget to give a permission to run the bash script and it will take a long time to process.

Do the same for HTTP1/1 with the following script (the only difference is ”- -h1" parameter).

The results obtained separately for the 25 ms, 75 ms, 150 ms, 250 ms, 500 ms and 1000 ms network delays and 0.1%, 0.3%, 0.5%, 1%, 2% and 5% packet loss values in the bash script are stored in h1 and h2 txt files where is ./nghttp2/src/ will be recorded. After you have obtained this data, you should take the averages and obtain the following graph.

Let’s interpret the results.

The lower values of the average page loading time are considered higher performance.

The results show that HTTP / 2 has a lower average page loading time than almost any latency and packet loss value. As seen in the graph, HTTP / 2 shows a more fixed and more stable increase in latency and loss values. High values of network latency showed significant differences in the average page loading time of HTTP / 2 and higher performance values were observed. When the average of all measurements is taken, the average packet download time of HTTP / 2 is estimated to be 14% lower than HTTP / 1.1.

--

--