0

I have upgraded to HTTP2 from http1.1 for a tomcat9 application. After this upgrade, I can see that the performance of the rest APIs is slow. I ran a load test for 1000 samples and as a result, HTTP1.1 has better throughput and average response time however I was expecting it to be for HTTP2.

is there any configuration that has to be done or am I missing something?

PS: The response Content-type is application/json type.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
theNextBigThing
  • 131
  • 3
  • 14
  • Are you comparing HTTPS over both? Do you make just one call each time (HTTP/2 is primarily better for the use case of multiple calls reusing the same connection and will be similar to HTTP/1.1 I’d just making one call)? Are your calls over low-latency, high bandwidth connections (e.g. within a data centre)? – Barry Pollard Feb 19 '20 at 06:58
  • This application is running in tomcat where 8080 port is exposed for http1.1 and 8443 port is exposed for http2 along with an SSL(HTTPs). I am using JMeter to create 1000 requests from concurrent threads. These requests are not one by one. – theNextBigThing Feb 19 '20 at 07:01

1 Answers1

3

You are comparing HTTP/1.1 without HTTPS with HTTP/2 with HTTPS. That’s not a true comparison of the protocols alone as HTTPS has significant overheads - particularly for just one connection.

Yes it’s true that HTTP/2 normally requires HTTPS as no browser supports HTTP/2 without HTTPS but then again browsers are increasingly warming against unsecured HTTP-only connections and limiting features like HTTP/2, Brotli, Service Workers, Geo... etc. to HTTPS anyway.

HTTP/2 over HTTPS can beat HTTP/1.1 over HTTP in certain circumstances but in general that’s a heck of a back foot to start on.

Additionally when making only one request per connection (like you are in jMeter using threads) the expense of HTTPS will be a large percentage of the connection due to the HTTPS handshake that needs to happen to set up the connection. Future requests on the same connection won’t have the same expense as in general the encryption/decryption part is relatively fast on modern hardware and so doesn’t create a noticeable delay - but the initial setup part definitely does.

Finally HTTP/2 is generally faster than HTTP/1.1 over slower, high latency connections due in large part to multiplexing. If testing over the same network, as I suspect you might be doing, where there are basically no network delays, then the benefit of HTTP/2 over HTTP/1.1 may not be apparent.

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
  • Okay, I checked with HTTPS for both HTTP/1.1 and HTTP/2. Still the results are far different. The HTTP/2 throughput is nearly half the throughput of HTTP/1.1. As there is no network delay and both the tests are happening locally, is it acceptable behavior? – theNextBigThing Feb 19 '20 at 09:38
  • That seems very unexpected to be honest. – Barry Pollard Feb 19 '20 at 10:36
  • can there be an issue with the content-type ( I am using the application/JSON. ) or java version since full http2 related functionalities are there in java9 and I am using java8? – theNextBigThing Feb 19 '20 at 11:17