-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: BenchmarkClientServerParallel4 hangs and is useless #20166
Comments
(At d286399, on linux/amd64) |
Might be related to #18753 with BenchmarkClientServerParallel64 on mac os - which is the same test just with more parallelism. I've see a similar problems on mac os with BenchmarkClientServerParallel4 and variants. The first 3 runs are fine, second time it is run thrice it dies with the error: can't assign requested address. Waiting a minute and trying again results in the same pattern - fine for first run, fails afterward, as opposed to trying again straight away which fails repeatedly, so it does seem to be exhausting resources by tying them up for too long. netstat -a after the test shows thousands of connections in state TIME_WAIT for a minute or two, but I guess that's normal?
|
CL https://golang.org/cl/49031 mentions this issue. |
I think this problem is caused by how are we using
When we use
I submitted a solution that I think fits with the tr := &Transport{}
defer tr.CloseIdleConnections()
c := &Client{Transport: tr} instead of |
Thank you for the investigation @xiam and for sending the CL. So for an updated, since Go1.12, we now have Client.CloseIdleConnections() https://golang.org/pkg/net/http/#Client.CloseIdleConnections -- committed on August 20th 2018 and in CL https://go-review.googlesource.com/130115. Following up with your suggestion, perhaps in that defer, we could invoke If so, and if you have the time, a CL from you following up your previous one https://go-review.googlesource.com/c/go/+/49031/, would be great for Go1.15. @bradfitz would also be happy to see more folks involved with net/http. Thank you! |
To disable the automatic connection cache (if that's what you need) you can configure the Transport: tr := &Transport{DisableKeepAlives: true}
c := &Client{Transport: tr} Depending on the timing, closing idle connections may not work as reliably or have no effect at all (because a connection may not be considered "idle", yet). You can also configure a maximum number of idle connections on the Transport. |
It seems the BenchmarkClientServerParallel4 benchmark sometimes hangs while running. Sometimes it needs to be killed (first example) and sometimes it recovers on its own, leading to useless numbers.
In any case, I can't get good numbers out of it.
I suspect it's consuming too many sockets and running out of addresses or something.
The text was updated successfully, but these errors were encountered: