Skip to content

Commit 37b77c3

Browse files
authored
fix(spanner): update dynamic channel pool default configuration (#13646)
Set Spanner DCP defaults to maxRpcPerChannel=25, minRpcPerChannel=15, scaleDownInterval=3m, initSize=4, maxChannels=10, minChannels=2. Internal Ref: go/dynamic-channel-pooling-non-sab
1 parent 9d78307 commit 37b77c3

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
144144

145145
// Dynamic Channel Pool (DCP) default values and bounds
146146
/** Default max concurrent RPCs per channel before triggering scale up. */
147-
public static final int DEFAULT_DYNAMIC_POOL_MAX_RPC = 90;
147+
public static final int DEFAULT_DYNAMIC_POOL_MAX_RPC = 25;
148148

149149
/** Default min concurrent RPCs per channel for scale down check. */
150150
public static final int DEFAULT_DYNAMIC_POOL_MIN_RPC = 15;
@@ -153,13 +153,13 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
153153
public static final Duration DEFAULT_DYNAMIC_POOL_SCALE_DOWN_INTERVAL = Duration.ofMinutes(3);
154154

155155
/** Default initial number of channels for dynamic pool. */
156-
public static final int DEFAULT_DYNAMIC_POOL_INITIAL_SIZE = 1;
156+
public static final int DEFAULT_DYNAMIC_POOL_INITIAL_SIZE = 4;
157157

158158
/** Default max number of channels for dynamic pool. */
159-
public static final int DEFAULT_DYNAMIC_POOL_MAX_CHANNELS = 256;
159+
public static final int DEFAULT_DYNAMIC_POOL_MAX_CHANNELS = 10;
160160

161161
/** Default min number of channels for dynamic pool. */
162-
public static final int DEFAULT_DYNAMIC_POOL_MIN_CHANNELS = 1;
162+
public static final int DEFAULT_DYNAMIC_POOL_MIN_CHANNELS = 2;
163163

164164
/**
165165
* Default affinity key lifetime for dynamic channel pool. This is how long to keep an affinity

java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,20 @@ public void testDynamicChannelPoolingDisabledWhenGrpcGcpDisabled() {
13441344
assertFalse(options.isDynamicChannelPoolEnabled());
13451345
}
13461346

1347+
@Test
1348+
public void testDynamicChannelPoolDefaultValues() {
1349+
// Pins the documented dynamic channel pool default values. If this test fails, the defaults
1350+
// changed: update these literals deliberately and call the change out in the PR description.
1351+
assertEquals(25, SpannerOptions.DEFAULT_DYNAMIC_POOL_MAX_RPC);
1352+
assertEquals(15, SpannerOptions.DEFAULT_DYNAMIC_POOL_MIN_RPC);
1353+
assertEquals(Duration.ofMinutes(3), SpannerOptions.DEFAULT_DYNAMIC_POOL_SCALE_DOWN_INTERVAL);
1354+
assertEquals(4, SpannerOptions.DEFAULT_DYNAMIC_POOL_INITIAL_SIZE);
1355+
assertEquals(10, SpannerOptions.DEFAULT_DYNAMIC_POOL_MAX_CHANNELS);
1356+
assertEquals(2, SpannerOptions.DEFAULT_DYNAMIC_POOL_MIN_CHANNELS);
1357+
assertEquals(Duration.ofMinutes(10), SpannerOptions.DEFAULT_DYNAMIC_POOL_AFFINITY_KEY_LIFETIME);
1358+
assertEquals(Duration.ofMinutes(1), SpannerOptions.DEFAULT_DYNAMIC_POOL_CLEANUP_INTERVAL);
1359+
}
1360+
13471361
@Test
13481362
public void testCreateDefaultDynamicChannelPoolOptions() {
13491363
// Test the static factory method for creating default options

0 commit comments

Comments
 (0)