Skip to content

Commit 38e5837

Browse files
authored
feat: lower maxInflightRequest setting so that connection pool can scale up more efficiently. (#2993)
* Update WriteToDefaultStream.java * Change to a working builder method * fix syntax error * include missing import * int to long * add explaination.
1 parent 6501ab5 commit 38e5837

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.api.core.ApiFuture;
2121
import com.google.api.core.ApiFutureCallback;
2222
import com.google.api.core.ApiFutures;
23+
import com.google.api.gax.batching.FlowControlSettings;
2324
import com.google.api.gax.core.FixedExecutorProvider;
2425
import com.google.api.gax.retrying.RetrySettings;
2526
import com.google.cloud.bigquery.BigQuery;
@@ -184,6 +185,9 @@ private JsonStreamWriter createStreamWriter(String tableName)
184185
.setChannelsPerCpu(2)
185186
.build())
186187
.setEnableConnectionPool(true)
188+
// This will allow connection pool to scale up better.
189+
.setFlowControlSettings(
190+
FlowControlSettings.newBuilder().setMaxOutstandingElementCount(100L).build())
187191
// If value is missing in json and there is a default value configured on bigquery
188192
// column, apply the default value to the missing value field.
189193
.setDefaultMissingValueInterpretation(

0 commit comments

Comments
 (0)