Modern applications often communicate with multiple AWS services. A .NET application might upload files to Amazon S3, store records in DynamoDB, publish messages to SQS, and retrieve information from other AWS services. As the number of requests increases, network performance becomes an important part of the application's overall performance.
A slow AWS request does not always mean that the AWS service is responding slowly. The application may be creating too many clients, opening unnecessary network connections, transferring large files through a single connection, or processing too many requests at the same time.
AWS Common Runtime (CRT) helps address some of these challenges. It is a collection of native libraries designed to provide efficient networking, HTTP communication, authentication, cryptographic operations, and other common functionality used by AWS SDKs and tools.
For .NET developers, understanding CRT is important because it provides building blocks for high-performance AWS communication. However, it is equally important to understand which CRT features are available through the .NET binding and which are provided directly by the AWS SDK for .NET.
This article explains how AWS CRT works, how it relates to .NET applications, and how to improve AWS client performance using practical development techniques.
What Is AWS Common Runtime?
AWS Common Runtime is a collection of open-source libraries written primarily in C. These libraries provide common functionality that AWS SDKs can use instead of implementing the same networking and low-level operations separately for every programming language.
The main goal of CRT is to provide efficient, reusable components for communication with AWS services.
For example, when an application sends an HTTP request to an AWS service, several operations happen behind the scenes:
- The application prepares the request.
- The SDK resolves the service endpoint.
- The request is signed using AWS authentication.
- A network connection is established or reused.
- The request is transmitted to the AWS service.
- The response is received and processed.
- The connection is returned to the connection pool when possible.
Each operation consumes resources. If the application performs thousands of requests, inefficient connection management or unnecessary processing can increase latency and resource usage.
CRT provides optimized components for some of these operations.
The AWS Common Runtime includes libraries for HTTP communication, authentication, cryptography, checksums, networking, event streams, and other shared functionality.
Important Components of AWS CRT
CRT is modular. Each library is responsible for a particular area of functionality. Applications and AWS SDKs can use only the components they need.
The following table explains some important components.
| Component | Purpose |
|---|
| aws-c-common | Provides common data structures, memory management, and threading utilities |
| aws-c-io | Handles networking, sockets, DNS, and event loops |
| aws-c-http | Provides HTTP/1.1 and HTTP/2 communication |
| aws-c-auth | Supports authentication and AWS request signing |
| aws-c-cal | Provides cryptographic operations |
| aws-checksums | Provides checksum calculations |
| aws-c-event-stream | Handles AWS event stream messages |
| aws-c-s3 | Provides high-throughput S3 transfer functionality |
These libraries work together when a CRT-based client needs to communicate with an AWS service.
For example, an HTTP client can use the networking and I/O components to manage connections, while the authentication components help prepare signed requests.
The advantage is that these capabilities can be reused across different AWS SDKs and tools.
How AWS CRT Improves Client Performance
Network communication is one of the most important performance factors in cloud applications. An application can have efficient business logic and database queries but still experience slow responses because of inefficient HTTP communication.
CRT focuses on improving some of the lower-level operations involved in network communication.
Efficient Network Communication
Traditional network communication can involve repeated connection setup, thread management, and data processing.
CRT provides networking components designed to handle these operations efficiently. Its I/O libraries use event-driven approaches for asynchronous network operations.
An event-driven design allows the runtime to manage multiple network operations without requiring a dedicated thread to remain blocked for every operation.
This can be useful for applications that perform many concurrent network requests.
For example, consider an application that needs to retrieve metadata for thousands of files stored in Amazon S3. If each request creates unnecessary networking resources, the application can consume more memory and CPU than required.
Efficient connection management helps reduce this overhead.
Connection Pooling
Opening a new network connection for every AWS request is expensive.
A new connection may require DNS resolution, TCP connection establishment, and TLS negotiation. Repeating these operations can increase request latency.
Connection pooling allows an application to reuse existing connections when possible.
For example, suppose an application sends 100 requests to the same AWS service. Instead of repeatedly creating and closing connections, a connection pool can reuse available connections.
This reduces connection setup overhead and can improve throughput.
Connection pooling is not unique to CRT. The standard .NET HTTP infrastructure also supports connection pooling. The important point is to configure and use the selected client correctly.
HTTP/2 Support
HTTP/2 allows multiple request streams to share a single connection. This is known as multiplexing.
With HTTP/1.1, concurrent requests may require multiple connections depending on the client implementation and workload. HTTP/2 can reduce the need for multiple connections in suitable scenarios.
The AWS CRT HTTP client supports HTTP/1.1 and HTTP/2 where the selected language binding provides those capabilities.
However, developers should not assume that every AWS service endpoint or every .NET SDK client automatically uses HTTP/2 through CRT.
Protocol support depends on the client implementation, service endpoint, and language binding.
DNS Load Balancing and Connection Health
A network connection that worked earlier may not always remain healthy. DNS records can change, endpoints can become unavailable, and network conditions can vary.
CRT's networking components provide capabilities such as DNS load balancing and health-based connection management.
These capabilities help clients manage network connections more effectively.
For applications that make frequent requests to cloud services, better connection management can reduce the impact of unhealthy connections and endpoint changes.
Efficient S3 Transfers
Amazon S3 is frequently used for storing documents, images, backups, logs, and large datasets.
A single network connection can limit the transfer speed of a large file, especially when the available network bandwidth is high.
The CRT includes a dedicated S3 client designed to improve transfer throughput. It can divide a large upload or download into multiple requests that run in parallel.
If one part fails, the client can retry the affected part instead of restarting the entire transfer.
However, there is an important .NET-specific limitation: the AWS CRT .NET binding supports the CRT HTTP client, but the dedicated CRT S3 client is not listed as supported for .NET in the current component availability information.
.NET developers should therefore use the AWS SDK for .NET transfer features, such as TransferUtility, for high-throughput S3 transfers rather than assuming that the CRT S3 client is available through the .NET binding.
Understanding AWS CRT Support in .NET
AWS CRT is available through language bindings for different programming languages. However, not every binding provides every CRT component.
The following table shows the component availability for .NET based on the current AWS CRT component support information.
| CRT capability | .NET support |
|---|
| HTTP client | Supported |
| HTTP/2 | Not listed as supported |
| Dedicated S3 client | Not listed as supported |
| MQTT client | Not listed as supported |
| SigV4 and SigV4a | Supported |
| Checksums | Supported |
This distinction matters when selecting a performance improvement strategy.
For example, a developer working with Java may have access to a CRT-based S3 client through the relevant Java SDK integration. A .NET developer should not copy that configuration and expect it to work with the .NET SDK.
The correct approach is to identify the available .NET functionality and select the appropriate client or transfer utility.
AWS CRT and AWS SDK for .NET 4.1
The relationship between AWS CRT and AWS SDK for .NET has also changed with version 4.1.
Earlier versions of the AWS SDK for .NET used CRT integration for certain features that were not directly available through the required .NET APIs.
Two examples were:
- SigV4a signing, which is used by features such as Amazon S3 Multi-Region Access Points.
- CRC64NVME checksum calculations for supported S3 operations.
Applications using these features needed the AWSSDK.Extensions.CrtIntegration package.
Starting with AWS SDK for .NET 4.1, the SDK no longer requires CRT for these features. A managed SigV4a implementation is included in AWSSDK.Core, and checksum calculations use System.IO.Hashing.
This means developers upgrading to SDK 4.1 do not need to add CRT integration just to use these signing and checksum capabilities.
However, this does not mean that AWS CRT itself has become unnecessary. The CRT remains a separate set of libraries with its own functionality, including the HTTP client.
Keep these two concepts separate:
| Area | Explanation |
|---|
| AWS SDK for .NET 4.1 | No longer requires CRT for SigV4a and CRC64NVME checksum functionality |
| AWS CRT .NET binding | Provides access to supported CRT components, including HTTP |
| Standard AWS SDK HTTP pipeline | Handles service communication through the SDK's configured HTTP infrastructure |
| CRT HTTP client | A separate HTTP implementation that can be used where supported and appropriately integrated |
Do not assume that installing the CRT packages automatically replaces the HTTP implementation used by every AWS SDK service client.
Installing AWS CRT Packages for .NET
If your application needs to use the CRT HTTP binding directly, you can add the relevant NuGet packages.
The AWS Common Runtime packages are published separately.
For example, the following commands install the base CRT and HTTP components:
dotnet add package AWSCRT
dotnet add package AWSCRT-HTTP
The packages provide .NET bindings for the underlying CRT libraries.
The project may also require additional component packages depending on the functionality being used.
You can inspect the installed dependencies with:
dotnet list package
For applications using AWS SDK for .NET 4.1, do not install CRT packages simply because the application communicates with AWS. The normal AWS SDK service clients already provide the required communication infrastructure.
Add CRT dependencies only when you have a specific feature or integration that requires them.
Also verify native runtime requirements for your deployment platform. Since CRT uses native libraries, the operating system, architecture, and deployment environment must be compatible with the packages being used.
Improving AWS Client Performance in a .NET Application
You do not need to introduce a new networking library to solve every AWS performance problem.
In many applications, the biggest improvements come from using the existing AWS SDK correctly.
Let's review some practical techniques.
Reuse AWS Service Clients
One of the most important performance practices is to reuse AWS service clients.
Classes such as AmazonS3Client, AmazonDynamoDBClient, and AmazonSQSClient are thread-safe and designed to be reused.
Creating a new client for every request can repeatedly initialize HTTP infrastructure and create unnecessary resource overhead.
For example, avoid this approach:
public async Task UploadAsync(
string bucketName,
string filePath)
{
using var client = new AmazonS3Client();
await client.PutObjectAsync(new PutObjectRequest
{
BucketName = bucketName,
Key = Path.GetFileName(filePath),
FilePath = filePath
});
}
This example creates a new S3 client whenever the method runs.
A better approach is to register the client once and inject it into application services.
In an ASP.NET Core application, use dependency injection:
using Amazon.S3;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAWSService<IAmazonS3>();
builder.Services.AddScoped<FileStorageService>();
var app = builder.Build();
app.Run();
The AddAWSService extension method from AWSSDK.Extensions.NETCore.Setup registers AWS service clients with a default singleton lifetime.
Now the service can receive the shared S3 client:
using Amazon.S3;
using Amazon.S3.Model;
public class FileStorageService
{
private readonly IAmazonS3 _s3Client;
public FileStorageService(IAmazonS3 s3Client)
{
_s3Client = s3Client;
}
public async Task UploadAsync(
string bucketName,
string filePath)
{
var request = new PutObjectRequest
{
BucketName = bucketName,
Key = Path.GetFileName(filePath),
FilePath = filePath
};
await _s3Client.PutObjectAsync(request);
}
}
The application can reuse the same client across multiple requests.
This avoids repeatedly creating HTTP infrastructure and supports connection pooling.
Use Asynchronous Operations
AWS SDK operations often involve network communication. Synchronous operations can block application threads while waiting for responses.
For ASP.NET Core applications, prefer asynchronous methods.
For example:
public async Task<string> GetItemAsync(
IAmazonS3 s3Client,
string bucketName,
string objectKey)
{
using var response = await s3Client.GetObjectAsync(
bucketName,
objectKey);
using var reader = new StreamReader(response.ResponseStream);
return await reader.ReadToEndAsync();
}
The method uses asynchronous operations for the network request and stream reading.
Avoid calling .Result or .Wait() on asynchronous SDK operations. Blocking asynchronous work can reduce scalability and may cause deadlocks in certain application environments.
Dispose S3 Responses and Streams
S3 responses that contain object streams must be disposed correctly.
When an application downloads an object, the response may hold an open HTTP connection while the stream is being consumed.
If the application does not dispose the response, connections may remain occupied longer than necessary.
For example:
public async Task DownloadAsync(
IAmazonS3 s3Client,
string bucketName,
string objectKey,
string destinationPath)
{
using var response = await s3Client.GetObjectAsync(
bucketName,
objectKey);
await response.WriteResponseStreamToFileAsync(
destinationPath,
false,
CancellationToken.None);
}
The using statement ensures that the response is disposed after the download operation finishes.
This is particularly important when downloading many objects.
If you only need object information such as size, content type, or last-modified time, use GetObjectMetadataAsync instead of downloading the entire object.
var metadata = await s3Client.GetObjectMetadataAsync(
bucketName,
objectKey);
Console.WriteLine(
$"Object size: {metadata.ContentLength}");
This avoids transferring the object body when only metadata is required.
Use TransferUtility for Large S3 Files
For large file uploads and downloads, the AWS SDK for .NET provides TransferUtility.
It manages multipart transfers and can upload multiple parts of a large file concurrently.
This is generally more suitable than manually implementing multipart upload logic.
Install the S3 SDK package if it is not already referenced:
dotnet add package AWSSDK.S3
You can then use TransferUtility:
using Amazon.S3;
using Amazon.S3.Transfer;
public class S3TransferService
{
private readonly IAmazonS3 _s3Client;
public S3TransferService(IAmazonS3 s3Client)
{
_s3Client = s3Client;
}
public async Task UploadLargeFileAsync(
string bucketName,
string filePath,
CancellationToken cancellationToken)
{
var transferUtility = new TransferUtility(_s3Client);
await transferUtility.UploadAsync(
filePath,
bucketName,
Path.GetFileName(filePath),
cancellationToken);
}
}
The transfer utility handles multipart upload operations when appropriate.
For applications that upload large files regularly, this can improve throughput and reduce the amount of custom transfer-management code.
The best transfer strategy depends on file size, available bandwidth, memory limits, and the number of concurrent transfers.
Limit Concurrent Requests
Sending too many requests at once can reduce application performance.
For example, imagine an application that needs to retrieve metadata for 10,000 S3 objects.
The following approach starts all operations without limiting concurrency:
var tasks = objectKeys.Select(key =>
s3Client.GetObjectMetadataAsync(
bucketName,
key));
await Task.WhenAll(tasks);
This can create a large number of pending operations and increase memory usage. It may also put unnecessary pressure on the connection pool and AWS service.
A better approach is to limit the number of concurrent operations.
For modern .NET applications, Parallel.ForEachAsync provides a convenient option:
var options = new ParallelOptions
{
MaxDegreeOfParallelism = 10
};
await Parallel.ForEachAsync(
objectKeys,
options,
async (key, cancellationToken) =>
{
await s3Client.GetObjectMetadataAsync(
bucketName,
key,
cancellationToken);
});
Here, the application processes a limited number of objects concurrently.
The value 10 is only an example. The correct concurrency level depends on the workload, AWS service limits, available network connections, and application resources.
Measure the results before increasing the limit.
Configure HTTP Connection Limits
Connection management becomes important when an application sends a large number of requests to the same AWS endpoint.
The AWS SDK for .NET exposes the MaxConnectionsPerServer setting through its client configuration.
For example:
using Amazon;
using Amazon.S3;
var config = new AmazonS3Config
{
RegionEndpoint = RegionEndpoint.APSouth1,
MaxConnectionsPerServer = 50
};
var s3Client = new AmazonS3Client(config);
This configuration sets the maximum number of concurrent connections per server for the relevant HTTP handler.
The value 50 is an example, not a universal recommendation.
On modern .NET targets, the default connection limit is effectively unlimited. Increasing the limit without measuring the workload may waste resources without improving throughput.
A useful starting point is to understand the expected peak number of concurrent requests to the same endpoint.
Monitor connection usage, request latency, CPU utilization, and timeout rates before changing this setting.
Measure Performance Before and After Optimization
Performance improvements should be based on measurements rather than assumptions.
Before changing the HTTP client or introducing CRT, collect a baseline for your application.
Useful measurements include:
| Metric | What it tells you |
|---|
| Average request latency | Typical time required to complete an AWS request |
| P95 latency | Time within which 95% of requests complete |
| P99 latency | Helps identify slow requests under load |
| Throughput | Number of completed operations per second |
| CPU usage | Processing overhead on the application server |
| Memory usage | Memory consumed during concurrent operations |
| Connection usage | Number of active network connections |
| Error rate | Frequency of failed or timed-out requests |
For example, you can use a Stopwatch to measure the duration of an S3 upload.
using System.Diagnostics;
using Amazon.S3;
using Amazon.S3.Model;
public async Task UploadWithTimingAsync(
IAmazonS3 s3Client,
string bucketName,
string filePath)
{
var stopwatch = Stopwatch.StartNew();
var request = new PutObjectRequest
{
BucketName = bucketName,
Key = Path.GetFileName(filePath),
FilePath = filePath
};
await s3Client.PutObjectAsync(request);
stopwatch.Stop();
Console.WriteLine(
$"Upload completed in {stopwatch.ElapsedMilliseconds} ms");
}
This example measures the duration of a single upload.
For production systems, use structured logging and metrics rather than writing performance information directly to the console.
Run tests with representative file sizes and request volumes. Also test under different network conditions and concurrency levels.
Compare the results before and after each optimization.
Avoid comparing two configurations if the test environments, file sizes, network conditions, or AWS Regions are different. Such differences can make the results misleading.
Common Performance Problems and Their Solutions
Even when an application uses AWS CRT or the standard AWS SDK, incorrect application patterns can still cause performance problems.
| Problem | Possible reason | Recommended solution |
|---|
| AWS requests are slow | New service clients are created repeatedly | Reuse long-lived service clients |
| Downloads hang under load | S3 responses or streams are not disposed | Dispose response objects after use |
| High memory usage | Too many concurrent operations | Limit concurrency |
| Large file uploads are slow | A single-stream transfer is being used | Use multipart transfers through TransferUtility |
| Frequent connection delays | Connection pooling is not being reused effectively | Reuse clients and review HTTP configuration |
| Requests time out | Network issues, excessive concurrency, or service throttling | Review timeout settings, concurrency, and retry behavior |
| CPU usage is high | Large amounts of data are being processed or checksums are expensive | Profile the application and review transfer patterns |
| CRT native library fails to load | Missing or incompatible native runtime dependency | Verify platform, architecture, and deployment files |
High Memory Usage During Large Transfers
Large file transfers can consume significant memory if the application loads entire files into memory before uploading or downloading them.
Prefer file-based transfer APIs when possible.
For example, using TransferUtility with a file path allows the SDK to manage the transfer without requiring the application to manually load the entire file into a byte array.
Also avoid starting hundreds of large transfers simultaneously. Limit concurrency based on the memory available to the application.
Socket Exhaustion
Socket exhaustion can occur when an application repeatedly creates short-lived HTTP clients or service clients and does not reuse the underlying connection infrastructure effectively.
Creating a new AWS service client for every operation can contribute to this problem.
Use dependency injection to register and reuse AWS clients.
Also make sure streaming responses are disposed properly so connections can return to the pool.
Unnecessary CRT Dependencies
Another common mistake is adding CRT packages without understanding which feature requires them.
For example, an application using AWS SDK for .NET 4.1 does not need AWSSDK.Extensions.CrtIntegration simply to support SigV4a signing or CRC64NVME checksums.
Those capabilities are included through the managed SDK implementation.
Before adding CRT packages, identify the exact component your application needs and confirm that it is supported by the .NET binding.
Best Practices for Production Applications
When improving AWS client performance in production, focus on the complete request lifecycle rather than only the HTTP implementation.
The following practices are useful:
- Reuse AWS service clients through dependency injection.
- Prefer asynchronous AWS SDK operations.
- Dispose S3 responses and streams deterministically.
- Use TransferUtility for large file transfers.
- Apply bounded concurrency instead of starting unlimited requests.
- Configure connection limits based on measured workload requirements.
- Use the correct AWS Region to avoid unnecessary network latency.
- Configure retry behavior for temporary failures and throttling.
- Monitor request latency, throughput, memory, and CPU usage.
- Keep AWS SDK and CRT dependencies compatible with the application's target framework.
- Test native dependencies in the same operating system and architecture used in production.
- Avoid introducing a new HTTP implementation without measuring its benefits.
For high-volume applications, load testing should be part of the optimization process. A configuration that performs well with ten requests may behave very differently with several hundred concurrent requests.
Advantages and Disadvantages of AWS CRT
AWS CRT provides reusable, performance-focused components for applications that need efficient communication with AWS services.
Advantages
CRT provides optimized networking and HTTP components that can help applications handle concurrent network operations efficiently.
Its modular design allows different AWS SDKs and tools to reuse common functionality. This reduces the need to implement networking and cryptographic operations separately for each programming language.
The HTTP client provides capabilities such as connection pooling, health-based connection management, and DNS load balancing.
The dedicated CRT S3 client can provide high-throughput multipart transfers in language bindings that support it.
CRT also provides native implementations of common low-level operations, which can be useful in performance-sensitive workloads.
Disadvantages and Considerations
CRT uses native libraries, so deployment requires attention to operating system and processor architecture compatibility.
Not every language binding supports every CRT component. In particular, .NET supports the CRT HTTP client, but the dedicated CRT S3 client is not currently listed as available through the .NET binding.
Introducing CRT also adds dependencies and deployment considerations. For applications that already perform well with the standard AWS SDK, the additional complexity may not provide meaningful benefits.
Finally, CRT is not a replacement for good application design. Creating too many clients, failing to dispose streams, or launching unlimited concurrent requests can still cause performance problems.
Conclusion
AWS Common Runtime provides a collection of optimized libraries that help AWS SDKs and tools handle networking, HTTP communication, authentication, and other common operations efficiently.
For .NET developers, CRT is useful to understand, but it is important to distinguish the available CRT components from the standard AWS SDK for .NET functionality.
The .NET CRT binding supports the CRT HTTP client, while the dedicated CRT S3 client is not currently listed as supported for .NET. For large S3 uploads and downloads, developers can use the SDK's TransferUtility instead.
In many .NET applications, the biggest performance improvements come from simple practices such as reusing service clients, using asynchronous methods, disposing response streams, limiting concurrency, and measuring connection usage.
Start by identifying the actual performance bottleneck. Then select the appropriate optimization and compare the results under realistic workloads.
A well-configured AWS client, combined with efficient application code, provides a reliable foundation for building scalable .NET applications on AWS.
Join the conversation! Your thoughts help the community grow.