Skip to content

chore: increased default number of total connections and connection p… #768

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

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions src/main/java/com/twilio/http/NetworkHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ public NetworkHttpClient(final RequestConfig requestConfig, final SocketConfig s

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultSocketConfig(socketConfig);
connectionManager.setDefaultMaxPerRoute(10);
connectionManager.setMaxTotal(10 * 2);
/*
* Example: Lets say client has one server.
* There are 4 servers on edge handling client request.
* Each request takes on an average 500ms (2 request per second)
* Total number request can be server in a second from a route: 20 * 4 * 2 (DefaultMaxPerRoute * edge servers * request per second)
*/
connectionManager.setDefaultMaxPerRoute(20);
connectionManager.setMaxTotal(100);

client = clientBuilder
.setConnectionManager(connectionManager)
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/twilio/http/ValidationClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,18 @@ public ValidationClient(final String accountSid,

final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultSocketConfig(socketConfig);

/*
* Example: Lets say client has one server.
* There are 4 servers on edge handling client request.
* Each request takes on an average 500ms (2 request per second)
* Total number request can be server in a second from a route: 20 * 4 * 2 (DefaultMaxPerRoute * edge servers * request per second)
*/
connectionManager.setDefaultMaxPerRoute(20);
connectionManager.setMaxTotal(100);
client = HttpClientBuilder.create()
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(requestConfig)
.setDefaultHeaders(headers)
.setMaxConnPerRoute(10)
.addInterceptorLast(new ValidationInterceptor(accountSid, credentialSid, signingKey, privateKey, algorithm))
.setRedirectStrategy(this.getRedirectStrategy())
.build();
Expand Down