-
Notifications
You must be signed in to change notification settings - Fork 29.1k
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP2 download of parallel requests is slower than HTTP1.1 #54874
Comments
Are you sure it's not the server that is being requested? Have you tried to reproduce with another http2 client?
How different were the speeds compared? CC @nodejs/http2 |
Yeah, I'm sure it's not the server that is being requested. I have tried
Here's the results of the runs I just completed on our internal APIs (25 parallel requests at the same time using the script I provided for node and for curl)
Also, I was able to get different results even when fetching |
I just ran node profiler for the script I provided fetching our internal API, and the results are weird... Here's the summary for http2
and for http1.1
http2 has less total ticks, but more GC ticks. I wonder if it could be somehow related to GC |
I guess something very odd is happening within http/2. I don't think the problem here is GC - it's 100% true that HTTP/2 consumes more resources than HTTP/1.1 but the difference should be lower. It seems that curl can progress all HTTP/2 streams in parallel, while we can't, and after a bit it becomes sequential. I wonder if @jasnell has some ideas. |
@mcollina I did some testing today and found some new insights. This does not happen for our internal endpoints with little data, those are processed faster with http2. When fetching a heavy endpoint with lots of data(json with lots of text, most of the text is contained in one particular field), http1.1 seems to be much faster. Besides, when fetching heavy endpoint, http1.1 receives smaller chunks on What's interesting: in cases when http1.1 is slower than http2, it receives larger chunks on |
Version
v20.17.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Define an http2 and http1.1 clients and fetch some data in parallel.
You can use the script below. If you run it using the following command, it will send 25 parallel requests using HTTP1.1
or you can run this command and it will send 25 parallel requests using HTTP2:
client.js
How often does it reproduce? Is there a required condition?
It's not quite stable, because sometimes http2 has the same performance or even better performance.
What is the expected behavior? Why is that the expected behavior?
I expect http2 to be faster or at least have the same performance as http1.1.
What do you see instead?
Instead, I often see that http1.1 requests are faster. Most of the times http2 took 25s to complete while http1.1 took 20s.
There's a problem, though, because those results are not consistent when using the URL I provided in the example.
But, the results are consistent with some internal APIs I'm working with. First, I thought there might be a problem with our internal APIs, but making 25 parallel requests to our internal APIs using
curl
has consistently the same performance on both http 1.1 and http2.I ran curl with the following command:
where config.txt looked like this:
Additional information
I was thinking the reason for such slowness would be TCP stall because http2 uses only 1 tcp connection, so I checked in wireshark how many tcp connections creates node vs curl when using http2, and both created only 1 tcp connection.
Also, I noticed node receives first 10 http2 requests randomly, but then sequentially, while http1 requests are all received randomly.
http2:
http1:
The text was updated successfully, but these errors were encountered: