Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General performance problems with the client #1700

Closed
Rodrigo-Andrade opened this issue Sep 10, 2020 · 3 comments · Fixed by #1705
Closed

General performance problems with the client #1700

Rodrigo-Andrade opened this issue Sep 10, 2020 · 3 comments · Fixed by #1705
Assignees
Labels
feature-request A feature should be added or improved. s3

Comments

@Rodrigo-Andrade
Copy link

The SDK is now the bottleneck in several of our systems, the dotnet ecosystem kept getting faster, fleshing out this issue more and more.

We are writing some custom implementations of the clients because the performance of the SDK is not acceptable for some of our workloads, greatly increasing the cost to use AWS services.

I propose that performance tests be included in your development pipeline.

Here is a sample trace from the S3 client as an exemple of the problems that permeate the SDK:

image

You can see that 20% of the CPU time spent sending this get request is at:

public static bool IsAmazonS3Endpoint(Uri uri)
{
      Match match = !(uri == (Uri) null) ? new Regex("^(.+\\.)?s3[.-]([a-z0-9-]+)\\.").Match(uri.Host) : throw new ArgumentNullException(nameof (uri));
      return (uri.Host.EndsWith("amazonaws.com", StringComparison.OrdinalIgnoreCase) || uri.Host.EndsWith("amazonaws.com.cn", StringComparison.OrdinalIgnoreCase)) && match.Success;
}

Every request runs this code.

@Rodrigo-Andrade Rodrigo-Andrade added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 10, 2020
@ppittle
Copy link
Member

ppittle commented Sep 12, 2020

Thinking about this, few things to try:

And looking further up the stack at AmazonS3KmsHandler.EvaluateIfSigV4Required, looks like we parses the request twice? We first check AmazonS3Uri.IsAmazonS3Endpoint(request) and then call new AmazonS3Uri(request) which repeats the Regex match.

We may be able to rework AmazonS3KmsHandler.EvaluateIfSigV4Required to reduce the duplicate match?

public class AmazonS3KmsHandler
{
    // try and reduce duplicate input checking
    internal static void EvaluateIfSigV4Required(IRequest request)
    {
            // Skip this for S3-compatible storage provider endpoints
            if (request.OriginalRequest is S3.Model.GetObjectRequest && 
                AmazonS3Uri.TryParseAmazonS3Uri(request.Endpoint, out var amazonS3Uri))  &&
                amazonS3Uri.Region != RegionEndpoint.USEast1)     
           {  
                 request.UseSigV4 = true;
           }
     }
}

Though, looking at AmazonS3Uri.TryParseAmazonS3Uri, that also will end up running a Regex check twice; but that feels like the better place to fix that problem.

@ashishdhingra ashishdhingra added A and removed needs-triage This issue or PR still needs to be triaged. labels Sep 14, 2020
@ppittle ppittle linked a pull request Sep 14, 2020 that will close this issue
10 tasks
@indy-singh
Copy link
Contributor

We've run into similar issues, and found that using pre-signed urls have alleviated a lot of the issues in case that helps @Rodrigo-Andrade

Regards,
Indy

@ppittle
Copy link
Member

ppittle commented Sep 25, 2020

Performance improvements are available in AWSSDK.S3 3.5.1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. s3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants