Fix InstantiatingGrpcChannelProvider's channel pool to play nicely with DirectPath #798
Conversation
…th DirectPath By default grpclb strategy for DirectPath is to create a subchannel for every address resolved by the grpclb and round robin over them. Unfortunately this doesn't work well when Channel pooling is enable in the InstantiatingGrpcChannelProvider, which will create multiple ManagedChannels, each containing a bunch of subchannels. Since channel pooling is needed to have good performance targeting CFEs, the solution here is to force each ManagedChannel to pick a single subchannel. Thus preserving the CFE behavior of a single ManagedChannel only containing a single subchannel.
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #798 +/- ##
============================================
+ Coverage 78.39% 78.43% +0.04%
Complexity 1106 1106
============================================
Files 198 198
Lines 4887 4897 +10
Branches 385 385
============================================
+ Hits 3831 3841 +10
Misses 887 887
Partials 169 169
Continue to review full report at Codecov.
|
Is there a link to the documentation somewhere about the configuration we're specifying? I couldn't find much on the |
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Outdated
Show resolved
Hide resolved
Maybe @WeiranFang can comment on the service config semantics? I don't know of any docs for the service config format. The config is the translation of the serverside config: See cl/243322471, for the original source. I reformatted the code and introduced local variables to make it easier to read. But unfortunately I can't offer more info on the semantics |
Hi @chingor13 , the usage of this I also found the spec for adding this API. As for the semantics of service config, check the GrpcLbConfig defined in service_config.proto Thanks! |
@chingor13 PTAL |
// cc @WeiranFang
By default grpclb strategy for DirectPath is to create a subchannel for
every address resolved by the grpclb and round robin over them.
Unfortunately this doesn't work well when Channel pooling is enable in
the InstantiatingGrpcChannelProvider, which will create multiple
ManagedChannels, each containing a bunch of subchannels.
Since channel pooling is needed to have good performance targeting CFEs,
the solution here is to force each ManagedChannel to pick a single
subchannel. Thus preserving the CFE behavior of a single ManagedChannel
only containing a single subchannel.
Unfortunately I couldn't figure out a reasonable way to write tests for this. ManagedChannelBuilder nor ManagedChannel provide a way from me to introspect what the current service config is, so a unit test w/o reflection is not possible. And bringing up a direct path like environment for a functional test is a bit too much.