net/http, crypto/tls: first HTTP request is consistently slower during TLS handshake in Go 1.17, but not 1.18 #50298
What version of Go are you using (
The text was updated successfully, but these errors were encountered:
In the test performed,
// Transport specifies the mechanism by which individual // HTTP requests are made. // If nil, DefaultTransport is used. Transport RoundTripper
If all 3 instances of an HTTP client end up reusing the default transport, there may be something cached and reused for future connections.
Maybe this isn't a problem because of
This doesn't appear to reproduce consistently for me with Go 1.18 Beta 1 and using my internet. I got a result that looks like:
So, it happened on first program execution, but not second and third.
I would imagine this can happen because of how the internet works: when making a request to a new server for the first time, routers take a bit longer to route packets the first time. For subsequent requests, those "first time" delays aren't incurred. For related discussion, see https://stackoverflow.com/questions/54078692/why-first-network-call-takes-more-time-than-subsequent-ones.
This is to say there may still be room for improvement in certain parts of
I tried running this with creating each client like this:
and the issue persists.
Yes, I was not clear about this in my original post - the line to track is
Makes sense, but I'm seeing the same thing when sending requests across different servers:
Thanks for clarifying.
I'm still not seeing the same difference you're describing on my machine, at least not with Go 1.18 Beta 1:
Edit: But I do see it with Go 1.17.5!
I'll let someone more familiar with