feat(transport): share TLS client session cache across NetworkPool transports - #556
Merged
SuperCoolPencil merged 1 commit intoJul 28, 2026
Conversation
…ansports Reuse one process-lifetime LRU ClientSessionCache so TLS session tickets survive Transport rebuilds and different poolKeys, while keeping a fresh *tls.Config per Transport.
Binary Size Analysis
|
Member
|
Thank you so much @superGekFordJ :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey there,
The current
http.Transportidle pool does a great job reusing connections and reducing overhead, but it looks like we might be missing a shared TLSClientSessionCache.Because of this, we aren't truly maximizing the handshake savings during scenarios like pause/resume, user network switching, or when workers are forced to dial a fresh connection (e.g., after CDN disconnects or during dynamic scale-ups).
So, let's introduce a package-level
tls.ClientSessionCache(I went with an LRU of 256) and wire it directly into theTLSClientConfigfor new transports! By doing this, anytime the engine actually needs to establish a new connection to the same host, we can consistently save a full 1-RTT on the TLS handshake overhead.I've put together a small patch to enable this. Let's see how much we can smooth out those reconnection bumps! Let me know your thoughts on this approach.
Greptile Summary
This PR enables TLS session resumption across transports created by NetworkPool.
Confidence Score: 5/5
The PR appears safe to merge with no actionable correctness or security issues identified.
The shared standard-library TLS session cache is safe for concurrent use, remains scoped by TLS server identity, and rejected or stale sessions transparently fall back to a full handshake.
What T-Rex did
Important Files Changed
Sequence Diagram
Reviews (1): Last reviewed commit: "feat(transport): share TLS client sessio..." | Re-trigger Greptile