All Products
Search
Document Center

Alibaba Cloud SDK:Connection pool of HTTP client

Last Updated:Sep 06, 2022

This topic describes how to configure an HTTP connection pool in Alibaba Cloud Darabonba SDK for Java.

You can use the Config object in the Darabonba SDK to configure a connection pool when you initialize the client. You can specify only the maximum number of idle connections for the connection pool. To prevent the memory leakage that is caused by excessive timeout period, the Darabonba SDK provides an optimal timeout period that is set to 10 seconds.
public static void main(String[] args) {
    Config config = new com.aliyun.teaopenapi.models.Config();
    config.setAccessKeyId("<accessKeyId>");
    config.setAccessKeySecret("<accessSecret>");
    config.setRegionId("<regionId>");
    // Specify the maximum number of idle connections.
    config.setMaxIdleConns(10);
    ecs20140526.Client client = new ecs20140526.Client(config);
}