xds: reuse GrpcXdsTransport and underlying gRPC channel to the same xDS server by ref-counting#12682
Open
danielzhaotongliu wants to merge 5 commits intogrpc:masterfrom
Open
Conversation
ejona86
reviewed
Mar 11, 2026
ejona86
approved these changes
Mar 12, 2026
Collaborator
Author
danielzhaotongliu
left a comment
There was a problem hiding this comment.
Forgot to push comments yesterday.
Addressed latest round of comments as well.
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.
This PR implements reusing the gRPC xDS transport (and underlying gRPC channel) to the same xDS server by ref-counting, which is already implemented in gRPC C++ (link) and gRPC Go (link). This optimization is expected to reduce memory footprint of the xDS management server and xDS enabled clients as channel establishment and lifecycle management of the connection is expensive.
GrpcXdsTransportinstances keyed by theBootstrapper.ServerInfoand eachGrpcXdsTransporthas a ref count. Note, the map cannot be simply keyed by the xDS server address as the client could have different channel credentials to the same xDS server, which should be counted as different transport instances.GrpcXdsTransportFactory.create()is called, the existing transport is reused if it already exists in the map and increment its ref count, otherwise create a new transport, store it in the map, and increment its ref count.GrpcXdsTransport.shutdown()is called, its ref count is decremented and the underlying gRPC channel is shut down when its ref count reaches zero.GrpcXdsTransportis different and orthogonal to the ref-counting of the xDS client keyed by the xDS server target name to allow for xDS-based fallback per gRFC A71.Prod risk level: Low
MAX_CONCURRENT_STREAMS.Tested:
Implementation details / context:
java.util.concurrent.ConcurrentHashMapAPIscomputeandcomputeIfPresentwhere the entire method invocation is performed atomically to achieve a concurrent and thread-safe solution which follows Java best practices.Alternatives considered: