Skip to content

Conversation

NickCraver
Copy link
Collaborator

@NickCraver NickCraver commented May 3, 2025

Previously when supporting earlier versions of .NET Framework, we did not have an async version of AuthenticateAsClient due to socket itself not having async handlers in earlier versions of netstandard. These days though with the supported target framework matrix, this can be fully async to prevent thread starvation specifically in the case where we're able to connect a socket but the server is overwhelmed and unable to finish TLS negotiations.

Example:
image

This is a case we've never seen stall before, where the server is able to accept connections but unable to complete TLS negotiation, so there's never been a reported stall raising this potential issue. Last night we saw it live on a major instance though. It's still TBD how this was manifesting server-side (could be a proxy stall in front of nodes, etc.) but we saw this against Redis Enterprise which we know a lot of folks use, so let's definitely improve anything we can as always.

Note that none of these methods take a cancellation token, so while we can avoid thread growth on the client side as a primary symptom of the case here, the server-side impact of backlogged but unconnected things may continue to grow. It's net better overall, though, and should help a bit on mass connection cases for some applications as well, in the cases TLS negotiation isn't instant.

NickCraver added 2 commits May 3, 2025 11:10
Previously when supporting earlier versions of .NET Framework, we did not have an async version of `AuthenticateAsClient` due to socket itself not having async handlers in earlier versions of `netstandard`. These days though, this can be fully async to prevent thread starvation specifically in the case where we're able to connect a socket but the server is overwhelmed and unable to finish TLS negotiations.

Note that none of these take a cancellation token, so while we can avoid thread growth on the client side as a primary symptom of the case here, the server-side impact of backlogged but unconnected things may continue to grow. It's net better overall, though, and should help a bit on mass connection cases for some applications as well, in the cases TLS negotiation isn't instant.
@NickCraver NickCraver marked this pull request as ready for review May 3, 2025 16:01
@NickCraver NickCraver requested review from mgravell and philon-msft May 3, 2025 16:01
@NickCraver NickCraver merged commit 28fbe78 into main May 3, 2025
7 checks passed
@NickCraver NickCraver deleted the user/craver/async-authenticate-as-client branch May 3, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants