AWS SDK for Java offers various HTTP clients that are used by the SDK to connect to AWS Service APIs. This can be broadly categorized into two categories:
For synchronous interactions with AWS services for lower latency, using synchronous service clients like
S3Client or
DynamoDBClient
you can use either the ApacheHttpClient
(default) or UrlConnectionHttpClient.
It is generally recommended to use UrlConnectionHttpClient
in Lambda because it is lightweight and minimizes jar size.
For async interactions with AWS services, you can use NettyNioAsyncHttpClient or AwsCrtAsyncHttpClient.
AwsCrtAsyncHttpClient
is recommended for Lambda because it has quicker loading times and thus leading to faster startups.
It also uses less memory as compared to NettyNioAsyncHttpClient. AwsCrtAsyncHttpClient
improves latency by up-to 76%,
provides up-to 14% reduction in memory usage and up-to 9% improvement in P90 latency.
Thumbs up this GitHub issue to add support for sync client APIs
to CRT Client.
One limitation of AwsCrtAsyncHttpClient
is that it currently does not support HTTP/2 protocol.
So if you are using the service SDK clients that require HTTP/2 support such as
KinesisAsyncClient
and TranscribeStreamingAsyncClient,
consider using NettyAsyncHttpClient instead.
To learn more, visit this AWS Blog.