Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.1 KB

3-Pool-EN.md

File metadata and controls

26 lines (21 loc) · 1.1 KB

← Client & Credentials | Connection Pool(中文) | Timeout →


Configure the connection pool

Multiple SDK clients share the same connection pool, configure the pool in the initialization phase of the client

// Create and initialize a DefaultAcsClient instance
DefaultProfile profile = DefaultProfile.getProfile(
"<your-region-id>",          // The region ID
"<your-access-key-id>",      // The AccessKey ID of the RAM account
"<your-access-key-secret>"); // The AccessKey Secret of the RAM account

// Multiple SDK clients share the same connection pool, set the
// parameters for this pool here such as maxRequestsPerHost, timeout, etc.
HttpClientConfig clientConfig = HttpClientConfig.getDefault();
clientConfig.setMaxRequestsPerHost(6);
clientConfig.setConnectionTimeoutMillis(30000L);
clientConfig.setMaxIdleConnections(20);

profile.setHttpClientConfig(clientConfig);
IAcsClient client = new DefaultAcsClient(profile);

← Client & Credentials | Connection Pool(中文) | Timeout →