BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Faster Startup Time and Lower Memory Usage: New CRT HTTP Client in AWS SDK for Java

Faster Startup Time and Lower Memory Usage: New CRT HTTP Client in AWS SDK for Java

AWS recently announced the general availability of the Common Runtime (CRT) HTTP Client in the AWS SDK for Java 2.x. The new asynchronous client provides faster SDK startup time and a smaller memory footprint improving Lambda serverless workloads.

In preview for more than two years, the new AwsCrtAsyncHttpClient is an asynchronous HTTP client built on top of the Java bindings of the Common Runtime libraries. Zoe Wang, software development engineer at AWS, explains:

You can use it as an alternative to the default Netty implementation of the SdkAsyncHttpClient interface. It offers faster SDK startup time and a smaller memory footprint, which is especially important with AWS Lambda, as well as lower P90 latency and enhanced connection management (...) We have observed an improvement of up to 76% in startup latency and a reduction of up to 14% in memory usage in Lambda.

AWS CRT HTTP client with improved startup time

Source: https://aws.amazon.com/blogs/developer/announcing-availability-of-the-aws-crt-http-client-in-the-aws-sdk-for-java-2-x/

In addition, AWS claims an improvement of up to 9% in P90 latency. According to the documentation, the new asynchronous client also provides better connection health management and DNS load balancing. Wang adds:

The AWS CRT HTTP client has a connection health option that ensures "unhealthy" connections are not being reused. Based on your use case, you can simply set a throughput threshold that determines whether a connection is healthy. If the connection falls below the set threshold for a configured amount of time, the AWS CRT HTTP client will treat the connection as unhealthy and close it, after the in-progress request finishes.

To use the new HTTP client, developers have to first add the aws-crt-client dependency to the pom.xml file.

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-crt-client</artifactId>
    <version>${aws.sdk.version}</version>
</dependency>

There are different ways to switch from the default Netty to the CRT client: specify it using the S3AsyncClient.builder(), setting the software.amazon.awssdk.http.async.service.impl property at JVM startup or directly in the code, with the client builder as the recommended option.

Released in 2018, the AWS SDK for Java 2.0 includes features like non-blocking IO, APIs for event streaming that implement the HTTP/2 protocol, and a pluggable HTTP implementation to further customize applications. The SDK includes by default the netty-nio-client dependency. To reduce the package size, AWS recommends removing it from the application when using the new HTTP client.

The aws-crt-client is available starting from version 2.20.0 of the Java 2 SDK.

About the Author

Rate this Article

Adoption
Style

BT