HTTP configuration - AWS SDK for Java
AWS services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with AWS services in China.

At Amazon Web Services (AWS), we’re focused on finding ways to improve our products and provide a better customer experience. To do that, we need your feedback. Please take 5 minutes of your time to share insights regarding your experience with Java Spring and your need for Spring integration with AWS.

Click here to take a quick survey

This survey is hosted by an external company (Qualtrics), so the link above does not lead to our website. Please note that AWS will own the data gathered via this survey, and will not share the information/results collected with survey respondents. AWS handles your information as described in the AWS Privacy Notice.

HTTP configuration

You can change the default configuration for HTTP clients in applications you build with the AWS SDK for Java. This section discusses how to configure HTTP clients and settings for the AWS SDK for Java 2.0. Some of the available settings including specifying which HTTP client to use, as well as setting max concurrency, connection timeout, and maximum retries.

You can use the NettyNioAsyncHttpClient or AwsCrtAsyncHttpClient for asynchronous clients. For more information, see Configuring the Netty-based HTTP client or Configuring the AWS CRT-based HTTP client.

For synchronous clients, you can use ApacheHttpClient. For more information about Apache HTTPClient, see HttpClient Overview.

For a full list of options you can set with these clients, see the AWS SDK for Java 2.x API Reference.

Setting maximum connections

You can set the maximum allowed number of open HTTP connections by setting the value of MAX_CONNECTIONS on a SdkHttpConfigurationOption object. Use that object to configure your HTTP client builder. (For example, ApacheHttpClient,

maxConcurrency method. The maxPendingConnectionAcquires method enables you to set the maximum requests allowed to queue up once max concurrency is reached.

  • Default for maxConcurrency: 50

  • Default for maxPendingConnectionAcquires: 10_000


Set the maximum connections to the number of concurrent transactions to avoid connection contentions and poor performance.

Timeouts and error handling

You can set options related to timeouts and handling errors with HTTP connections.

  • API call attempt timeout

    The API call attempt timeout is the amount of time to wait for the HTTP request to complete before timing out.

    To set this value yourself, use the apiCallAttemptTimeout method.

  • Connection Time to Live (TTL)

    By default, the SDK will attempt to reuse HTTP connections as long as possible. In failure situations where a connection is established to a server that has been brought out of service, having a finite TTL can help with application recovery. For example, setting a 15 minute TTL will ensure that even if you have a connection established to a server that is experiencing issues, you’ll reestablish a connection to a new server within 15 minutes.

    To set the HTTP connection TTL, use the http/SdkHttpConfigurationOption.html#CONNECTION_TIME_TO_LIVE> method.

  • Maximum Error Retries

    The default maximum retry count for retriable errors is 3. You can set a different value by using the numRetries method.

Local address

To set the local address that the HTTP client will bind to, use ClientConfiguration.setLocalAddress.