Comparing HTTP1 vs HTTP2 performance

Hello, I am trying to run a test to compare the performance of my api when using http1.1 and http2. I have set up a simple Gatling script in Java to inject constant number of users every second, where each user makes a call to my api. I have limited connections per host to 1 and enabled sharing connections, in the hopes that virtual users will not open any new connections and use the single connection specified. So I run my test with http1 then with http2 but unfortunately I’m not able to see a performance difference in Gatling in terms of response time. Will gatling behave the way I am expecting? (What I’m expecting is that with that configuration, all virtual users will share 1 connection and when using http1 the users will have to wait until the connection is free for use to make their request but with http2 they will be able to all send their request through the connection using multiplexing)
Thanks a lot for your time and would appreciate some insight into how to test with Gatling to show the difference between http1 and 2.

Once you’re using a global connection pool and have reached a stable number of connections, there’s no reason for HTTP/2 to be faster than HTTP/1.

The only use case that really benefits from HTTP/2 in terms of performance is a browser fetching lots of concurrent resources from the same hosts when loading a page.

Thanks for your prompt response!
I would expect that if we have 5 users sharing a single connection to make their requests, then with http1 the users have to wait for each other’s requests to complete before making their own. Whereas with HTTP2 the 5 users should be able to make their requests concurrently. Is this not a correct understanding? So with Gatling I’m trying to limit the connections opened by the users to just 1 by setting maxConnectionPerHost to 1 AND simultaneously setting shareConnection. Does this give me the desired behaviour in Gatling of 1 global connection shared by all users or will each virtual user still open their own connection?


maxConnectionPerHost is only an option for resources fetching over HTTP/1.

1 Like

As described in the documentation:

By default, Gatling caps the number of concurrent connections per remote host per virtual user to 6, […]

So, this value is per virtual user, not global to the simulation.

For you test, you should try to implement full scenario where each user will request different things concurrently (with resources?)

You should then see the difference.


1 Like

Each user of mine does post requests so can I use resources for that or is it only for get? How can I make concurrent post requests? (That use a fixed connection pool)

Is there a way to cap global number of connections across all users? Alternatively, is there a way for a user to make concurrent post requests?

No, neither are possible.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.