-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Excessive TLS connections - CPU/Memory Usage #3067
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
Comments
Thanks for reaching out @nbaztec. The connection issue you are experiencing is most likely due to the Kinesis sever closing the connection after the 6-10 second window due to inactivity. Since the server is probably closing the connection due to inactivity the client's configuration is not making a difference. This can be verified with httptrace.ClientTrace. The httptrace.GotConnInfo value passed into the Each time the sever closes the connection, the client will need to re-establish the connection. The Go HTTP client's transport TLS sessions are not resumed between re-established connections. A new TLS session will need to be created for the new connection. This is the reason for the TLS connection activity. One potential workaround for this issue is to space reporting records out in order to reduce the duration of time between calls to Kinesis's API does support HTTP without TLS, which would remove the overhead of the TLS session setup, but would make your record data visible on an network. |
Thanks @jasdel for the added discovery. That was our guess as well with Kinesis closing connections altogether. And in that light the approach of using channels to better throttle/batch the So far, as you've pointed out correctly that there's no proper library solution that can be made available to mitigate the issue, thereby we shall be looking to mitigate it with go channels instead. Thanks! |
Hi @nbaztec, please do let us know if you require further assistance from us on this. Otherwise feel free to close the issue, or we can let it auto-close due to inactivity. |
Hi! Thanks for the help. We've successfully resolved the issue by tweaking the keepalive parameters for the connection on our end. Closing this one. |
@nbaztec could you please describe how did you change the keep-alive parameters specifically to resolve this problem? We have exactly the same issue with TLS reconnections accessing DynamoDB. We have configured OTOH, I don't understand why keep-alive even matters under load.
If there is a performance problem, why there are long periods of connection inactivity? (The same reasoning applies to our case with DynamoDB as well.) @jasdel do you have some insights on this? |
@leventov I mitigated it by explicitly setting the keep-alive parameters to the following in the
This is my hypothesis and some memory jogging from the profiler: The |
@nbaztec thanks for reply! It seems to me that setting It might be that these issues are related: golang/go#20960, golang/go#42650. Also, surprisingly, |
@leventov Hi leventov, I am also facing the issue of CPU usage while having concurrent requests requiring TLS negotiations with dynamodb. Can you please explain how you resolved this issue ? |
Uh oh!
There was an error while loading. Please reload this page.
Version of AWS SDK for Go?
v1.26.8
Version of Go (
go version
)?go version go1.13 darwin/amd64
What issue did you see?
Profiling the app shows that the app was spending much resources while handling TLS handshakes.
Over a third of CPU/Memory was being used for TLS negotiation (which after setting the
MaxIdleConnsPerHost
seemed to be better)However, even when
IdleConnTimeout
is set, the connections still seem to be discarded after around ~6-8 seconds of inactivity and a new TLS negotiation is initiated.Steps to reproduce
net/http/transport.go
addTLS()
is invoked, for every request that is 6-10 seconds apart to start a new TLS session.Expected
One would expect that the TLS session would only be initiated once, and be re-used from idle sessions
The text was updated successfully, but these errors were encountered: