AWS SDK for Java
Developer Guide

HTTP Transport Configuration

You can use the NettyNioAsyncHttpClient for asynchronous clients or the ApacheHttpClient for synchronous clients to set HTTP transport settings. For a full list of options you can set with these clients, see the AWS SDK for Java 2.0 Reference.

Add a dependency on the netty-nio-client in your POM to use the NettyNioAsyncHttpClient.

POM Entry

<dependency> <artifactId>netty-nio-client</artifactId> <groupId>software.amazon.awssdk</groupId> <version>2.0.0</version> </dependency>

Maximum Connections

You can set the maximum allowed number of open HTTP connections by using the 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

Important

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

Use the HTTP client builder to have the SDK manage its lifecycle. The HTTP client will be closed for you when the service client is shut down.

Imports

import software.amazon.awssdk.http.async.SdkAsyncHttpClient; import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;

Code

KinesisAsyncClient client = KinesisAsyncClient.builder() .httpClientBuilder(NettyNioAsyncHttpClient.builder() .maxConcurrency(100) .maxPendingConnectionAcquires(10_000)) .build();

You can also pass the HTTP client directly to the service client if you want to manage the lifecycle yourself.

Code

SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder() .maxConcurrency(100) .maxPendingConnectionAcquires(10_000) .build(); KinesisAsyncClient kinesisClient = KinesisAsyncClient.builder() .httpClient(httpClient) .build(); httpClient.close();

On this page: