Skip to content

HTTP connection sharing across managed channels #12572

@shivamgupta1

Description

@shivamgupta1

Is your feature request related to a problem?

gRPC usage within our organization requires creation of several managed channels, each with a unique authority, for various endpoints within the same server app. This leads to creation of multiple redundant HTTP/2 connections that could've just been re-used. The current NettyChannelBuilder impl doesn't feature any option to enable transport level connection re-use.

Describe the solution you'd like

NettyChannelBuilder currently defines NettyTransportFactory as a nested class and the implementation spawns a new NettyClientTransport each time it's called.

I'd like to:

  • Add a new method to NettyChannelBuilder that allows injecting a custom ClientTransportFactoryBuilder. If this is too much flexibility, then we can just add a new method to enable connection re-use.
  • Create a new implementation of ClientTransportFactory that returns a preexisting (if available) NettyClientTransport wrapped by a new decorator. The decorator object will ensure that methods like start will still provide appropriate lifecycle notifications to the supplied listeners.

Describe alternatives you've considered

We tried re-using subchannels within the loadbalancer but it isn't clean. For e.g., the synchronization context isn't shared across different loadbalancer objects.

Additional context

If the gRPC maintainers see value in this addition and agree with the proposed approach, I can send a PR for this feature soon.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions