Closed Christian-health closed 3 months ago
If you are really using go 1.14, to start with, please upgrade to newer version and see if it changes.
If you are really using go 1.14, to start with, please upgrade to newer version and see if it changes.
Thank you for your response. This issue has been resolved.
server-side code:
srv := &http.Server{
Addr: fmt.Sprintf("%s:%d", serverCfg.Addr, serverCfg.Port),
Handler: e,
// If the server has the following two lines of code, it will be able to release the client's connection from the server.
ReadTimeout: time.Duration(serverCfg.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(serverCfg.WriteTimeout) * time.Second,
}
client-side code:
HTTPTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: time.Duration(100) * time.Second,
KeepAlive: time.Duration(100) * time.Second,
}).Dial,
TLSHandshakeTimeout: time.Duration(100) * time.Second,
ExpectContinueTimeout: time.Duration(100) * time.Second,
// If the client has the following three lines of code, it will ensure that the number of client connections created is limited.
MaxIdleConnsPerHost: 100,
MaxIdleConns: 100,
IdleConnTimeout: 100,
}
The issue is that the server did not configure a timeout, and the client did not limit the number of connections created and used a connection pool. As a result, each time the client sent data, a new connection was created. Additionally, Go's default behavior open keep-alive. This led to a large number of connections not being released, eventually resulting in an out-of-memory (OOM) error."
Issue Description
I am using the Go echo framework to set up an HTTPS server, and it's running in a pod. After a period of time, this pod experiences an Out-Of-Memory (OOM) issue, gets killed, and is rebuilt. I noticed that there are a large number of HTTP request connections that are not being released. Additionally, for each request, a new goroutine is created. These goroutines show a significant I/O wait time, for example, 5801 minutes.
Could you please help analyze what might be the cause of this issue?
Version/commit
go1.14 echo