@@ -53,12 +53,19 @@ public class DatastoreOptions extends ServiceOptions<Datastore, DatastoreOptions
5353 private static final String DEFAULT_DATABASE_ID = "" ;
5454 public static final String PROJECT_ID_ENV_VAR = "DATASTORE_PROJECT_ID" ;
5555 public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST" ;
56+
57+ // Default to a slightly larger channel count to handle a larger initial QPS (up to ~500 QPS as
58+ // each channel can handle 100 max streams). This default remains a bit conservative and will
59+ // rely on the ChannelPool to resize according to the client's average load.
5660 public static final int INIT_CHANNEL_COUNT = 5 ;
61+ // Default to be larger than Gax's default (2) to better scale with spikes in requests
5762 static final int CHANNEL_POOL_DEFAULT_RESIZE_DELTA = 5 ;
58- // Configure this default to be 100 to match the typical default `MAX_CONCURRENT_STREAMS`.
59- // Larger values *may* experience possible client-side queueing as excess streams cannot be
60- // multiplexed onto a full Http2 connection.
61- static final int CHANNEL_POOL_MAX_RPCS_PER_CHANNEL = 100 ;
63+
64+ // Configure the min and max RPC/Channel default in accordance to Datastore configuration guide:
65+ // https://docs.cloud.google.com/datastore/docs/java-client-grpc#connection_pool_configuration
66+ static final int CHANNEL_POOL_MIN_RPCS_PER_CHANNEL = 10 ;
67+ static final int CHANNEL_POOL_MAX_RPCS_PER_CHANNEL = 50 ;
68+
6269 public static final int MIN_CHANNEL_COUNT = 1 ;
6370
6471 // This is a default max channel constant value set to handle the default initial channel
@@ -246,11 +253,13 @@ private DatastoreOptions(Builder builder) {
246253 // Datastore sets the initial channel pool count to be 5 channels to allow better handle
247254 // large loads of requests and the resize delta to be 5 to scale quicker. In cases of low
248255 // load, the channel count will scale down as needed and memory will be freed. The default
249- // configuration is set to try and handle ~500 QPS and will scale up and down as needed.
256+ // configuration is set to try and handle an average of ~250 QPS and will scale up and down
257+ // as needed.
250258 ChannelPoolSettings datastoreChannelPoolSettings =
251259 ChannelPoolSettings .builder ()
252260 .setInitialChannelCount (INIT_CHANNEL_COUNT )
253261 .setMinChannelCount (MIN_CHANNEL_COUNT )
262+ .setMinRpcsPerChannel (CHANNEL_POOL_MIN_RPCS_PER_CHANNEL )
254263 .setMaxRpcsPerChannel (CHANNEL_POOL_MAX_RPCS_PER_CHANNEL )
255264 .setMaxResizeDelta (CHANNEL_POOL_DEFAULT_RESIZE_DELTA )
256265 .build ();
0 commit comments