Advanced configuration
Configure HTTP connection pools, HTTPS requests, proxies, timeouts, and retry mechanisms in the Alibaba Cloud SDK to optimize performance, strengthen security, and improve reliability in high-concurrency, restricted-network, or unstable-network scenarios.
HTTP connection pool configuration
Scenarios
-
High-concurrency requests: When your application sends many HTTP requests simultaneously, a connection pool reuses existing TCP connections and reduces the overhead of frequent connection creation and teardown.
-
Performance optimization: Configuring the pool size (for example, the maximum number of connections) prevents resource exhaustion and improves request processing efficiency.
Example scenarios
-
Your application needs to make concurrent calls to multiple Alibaba Cloud services, such as OSS, ECS, and RDS.
-
When you upload files to OSS in batches, a connection pool can significantly increase the upload speed.
For more information, see HTTP connection pool configuration.
HTTPS request configuration
Scenarios
-
Data security requirements: HTTPS uses SSL/TLS to encrypt data in transit, preventing interception or tampering and ensuring data integrity.
-
Compliance requirements: Some industries, such as finance and healthcare, have strict data transmission security requirements that mandate the use of HTTPS.
Example scenarios
-
Your application needs to retrieve sensitive data, such as billing information or private user data, from an Alibaba Cloud API.
-
You need to comply with GDPR or other data protection regulations.
For more information, see HTTPS request configuration.
Proxy configuration
Scenarios
-
Restricted network environments: If your application runs behind a firewall or on a corporate intranet that requires a proxy to reach external networks, configure a proxy to route requests to Alibaba Cloud services.
-
Traffic monitoring: During development or testing, you can use a proxy to capture and analyze request traffic for debugging.
Example scenarios
-
Your application is deployed on a corporate intranet and needs to access Alibaba Cloud services through an HTTP/HTTPS proxy.
-
Multiple applications within a company share a single proxy server. The proxy centrally manages and schedules requests to external services.
For more information, see Proxy configuration.
Timeout mechanism
Scenarios
-
Unstable networks: When network latency is high or service responses are slow, a reasonable timeout prevents requests from hanging indefinitely.
-
User experience optimization: In user-facing applications, setting a timeout prevents users from experiencing long waits when a service is unavailable.
Example scenarios
-
If a network interruption occurs while a user is uploading a large file to OSS, setting a timeout can promptly stop the request and notify the user to try again.
-
When you call time-consuming APIs, such as those for batch operations, setting a timeout can prevent the request from waiting indefinitely.
For more information, see Timeout configuration.
Retry mechanism
Scenarios
-
Network jitter: When requests fail due to an unstable network, a retry mechanism automatically resends the request to increase the success rate.
-
Temporary service unavailability: When an Alibaba Cloud service is temporarily unavailable, retries help the application recover automatically.
Example scenario
Your application encounters intermittent network issues when calling an Alibaba Cloud service. By configuring the number of retries and the retry interval, you can increase the request success rate.
For more information, see Retry policy configuration.