Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: resizing channel pool size based on the work load #1271

Merged
merged 3 commits into from
May 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.gax.batching.FlowController.LimitExceededBehavior;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.grpc.ChannelPoolSettings;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.FixedHeaderProvider;
Expand Down Expand Up @@ -315,7 +316,13 @@ public Map<String, String> getJwtAudienceMapping() {
/** Returns a builder for the default ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return BigtableStubSettings.defaultGrpcTransportProviderBuilder()
.setPoolSize(getDefaultChannelPoolSize())
.setChannelPoolSettings(
ChannelPoolSettings.builder()
.setInitialChannelCount(2)
.setMinRpcsPerChannel(1)
.setMaxRpcsPerChannel(50)
.setPreemptiveRefreshEnabled(true)
.build())
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE)
.setKeepAliveTime(Duration.ofSeconds(30)) // sends ping in this interval
.setKeepAliveTimeout(
Expand All @@ -325,11 +332,6 @@ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProvi
.setAttemptDirectPath(true);
}

static int getDefaultChannelPoolSize() {
// TODO: tune channels
return 2 * Runtime.getRuntime().availableProcessors();
}

@SuppressWarnings("WeakerAccess")
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
Expand Down Expand Up @@ -658,9 +660,7 @@ private Builder() {
copyRetrySettings(baseDefaults.mutateRowSettings(), mutateRowSettings);

long maxBulkMutateElementPerBatch = 100L;
// Enables bulkMutate to support 10 outstanding batches upto per channel or up to 20K entries.
long maxBulkMutateOutstandingElementCount =
Math.min(20_000L, 10L * maxBulkMutateElementPerBatch * getDefaultChannelPoolSize());
long maxBulkMutateOutstandingElementCount = 20_000L;

bulkMutateRowsSettings =
BigtableBatchingCallSettings.newBuilder(new MutateRowsBatchingDescriptor())
Expand All @@ -682,9 +682,7 @@ private Builder() {

long maxBulkReadElementPerBatch = 100L;
long maxBulkReadRequestSizePerBatch = 400L * 1024L;
// Enables bulkRead to support 10 outstanding batches per channel
long maxBulkReadOutstandingElementCount =
10L * maxBulkReadElementPerBatch * getDefaultChannelPoolSize();
long maxBulkReadOutstandingElementCount = 20_000L;

bulkReadRowsSettings =
BigtableBulkReadRowsCallSettings.newBuilder(new ReadRowsBatchingDescriptor())
Expand Down