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: read: connection reset by peer under high load #20960
Comments
I've been seeing similar issues with a similar set up where the server is on Go 1.6 while the client, which is making many concurrent requests, is on Go 1.9.2. Are we aware of what causes this? Seems like some kind of unintentional in-build rate limiting? |
Go has no built-in rate limiting. If you get broken network connections, they might be real (a peer really did disconnect), or they might be from hitting kernel limits on one of the sides. |
Can anybody reproduce this and investigate? |
Adding a comment to remind myself but: I’ve seen similar issues with a should have time to investigate in the next month or so. |
In my opinion this issue occurs when the response is streamed into a dynamic allocated buffer. No error is thrown when conn.Read() is send to a buffer with a fixed length. Notice: even when the error is thrown, the response is buffered correct and complete. GO Version I used: 1.10.3 |
I am also seeing this issue on http load testing. Myabe I am hitting kernel tcp stack limits. @bradfitz any idea how to check if this is kernel issue? |
I am seeing this error frequently ( I am running the client and server both on the same "localhost", and both are running a managed pool of "worker" goroutines in an attempt to limit the demand for resources. The client and server each have 350+ goroutines (as reported by I can run the same code on Ubuntu 18.04 LTS with more cores, memory, sockets, etc, and I eventually run into the same error message, although at a higher traffic load. If there is a kernel limit, it would be nice to know what it is, so we could write our code so that it intentionally stays below that limit, rather than tweaking parameters and hoping it won't be a problem. I see this topic was active a year ago, ... has there been any progress on this in the past year @bradfitz ? |
Can I retry the HTTP request in second? |
I also see this issue under macOS where server and client talk over localhost. I don't know the exact cause of the problem but running Or both. I keep seeing For my project that's not needed and I could solve the problem by limiting number of concurrent connections. Solving the problem in my code by limiting number of goroutines seemed arbitrary and still occasionally failed. Limiting |
Also hitting this issue. Im running 1000 concurrent connections at it eventually hits this also on OSX with file descriptors bumped up from default (256) to 4096. See a lot of stuff about this, possibly only an issue on OSX |
I'm also running into this issue with the latest release of Go. No matter what I try, I keep getting these "connection reset by peer". Netstat show's hundreds of connections in TIME_WAIT state, even after shutting down my client.
The problem still happens with a Max Idle Connections of 1, and using runtime.GOMAXPROCS(1). I also try calling transport.CloseIdleConnections() after each goroutine, but according to netstat they still show up as "TIME_WAIT". |
I manage to solve my TIME_WAIT problem using this article: http://tleyden.github.io/blog/2016/11/21/tuning-the-go-http-client-library-for-load-testing/ |
@gabrielcalderon it doesn't fix the problem completely. Idle connections do not limit the number of connections Go could open. If you exhausted idle connections for any reason, Go will start opening new ones and cause TIME_WAIT problem again. What fixes the problem is |
Just to update. my issue was related to OSX and its defaults.. having tweakes the following settings I can now push 1000 concurrent transactions |
The only way I was able to fix it was to limit the number of concurrent transactions to be half the number of MaxIdleConns. |
@REPTILEHAUS Thanks for that.. This worked well for me.. Don't think "ulimit" was an issue, as it was set to "unlimited" already. Can someone give an insight into, what could be the side-effects, if I were to increase kern.ipc.somaxconn to an abnormally high number ? |
Works for me on Mac OS @REPTILEHAUS . |
have same issue |
For me, after doing this change, the error changed to |
This commit prints out an error with a breadcrumb on macOS to tweak a kernel setting (`kern.ipc.somaxconn`) to allow the test to pass. Fixes: ``` [FAILED] Unexpected error: <*net.OpError | 0xc0014887d0>: { Op: "read", Net: "tcp", Source: <*net.TCPAddr | 0xc0008929c0>{IP: [127, 0, 0, 1], Port: 57620, Zone: ""}, Addr: <*net.TCPAddr | 0xc0008929f0>{IP: [127, 0, 0, 1], Port: 6587, Zone: ""}, Err: <*os.SyscallError | 0xc00015e400>{ Syscall: "read", Err: <syscall.Errno>0x36, }, } read tcp 127.0.0.1:57620->127.0.0.1:6587: read: connection reset by peer occurred In [It] at: /Volumes/workspace/bosh-dns-release/src/bosh-dns/dns/main_test.go:1480 @ 02/19/23 17:10:05.539 ``` Thanks <golang/go#20960 (comment)>
What version of Go are you using (
go version
)?go1.8.3
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="linux"
What did you do?
sysctl -p
.Server https://play.golang.org/p/B3UCQ_4mWm
Client https://play.golang.org/p/_XQRqp8K5b
What did you expect to see?
No errors at all.
What did you see instead?
Errors like the following:
The text was updated successfully, but these errors were encountered: