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

AWSSDK.CloudFront is slower than AWSSDK.S3 - Signed URL Generation #3130

Open
SonalCalcey opened this issue Dec 14, 2023 · 5 comments
Open
Labels
bug This issue is a bug. module/sdk-custom needs-investigation p2 This is a standard priority issue

Comments

@SonalCalcey
Copy link

Describe the bug

Previous issue
Because of the above issue, we are just wondering if there is any issue on the CloudFront as well. Because compared to S3 the CloudFront Response time is x6 or x5 times slower than S3.

These two methods (PlayerSummaryFull and UpdatePlayerProfilePicture) use S3 or CloudFront to Generate Signed URLs.
The Following two benchmark snapshots are by using S3 and CloudFront respectively as media content providers.


AWSSDK.S3 - 3.7.304.7

s3 using latest only
Benchmark log: Benchmark-using-S3.log


AWSSDK.CloudFront - 3.7.301.11

cloud front using latest only
Benchmark log: Benchmark-using-CloudFront.log


Sorry for not having Multiple version comparisons or more details. The reason for providing these details is FYI to identify if there is any performance degradation on the CloudFront as well.

Expected Behavior

No response

Current Behavior

No response

Reproduction Steps

No response

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.CORE - 3.7.300.18
AWSSDK.S3 - 3.7.304.7
AWSSDK.CloudFront - 3.7.301.11

Targeted .NET Platform

.NET Framework 7

Operating System and version

Windows 10 Enterprise

@SonalCalcey SonalCalcey added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 14, 2023
@ashishdhingra
Copy link
Contributor

@SonalCalcey Good morning. The fix merged in other issue #3122 was made in AWSSDK.Core and hence should have propagated to CloudFront package as well. Do you have performance benchmarks between different versions of AWSSDK.CloudFront rather than comparing it with AWSSDK.S3?

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 14, 2023
@SonalCalcey
Copy link
Author

Hi @ashishdhingra Good morning. yes, I have a couple of benchmarks using AWSSDK.CloudFront.

AWSSDK.CloudFront - 3.7.301.12

CloudFront -  3 7 301 12 - CORE - 3 7 300 19


AWSSDK.CloudFront - 3.7.300.5

CloudFront -  3 7 300 5 - CORE - 3 7 300 19


AWSSDK.CloudFront - 3.7.0

CloudFront -  3 7 0 - CORE - 3 7 300 19

All are using AWSSDK.CORE - 3.7.300.19

Thanks,
Sonal

@ashishdhingra ashishdhingra added needs-investigation and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Dec 15, 2023
@ashishdhingra
Copy link
Contributor

@SonalCalcey Thanks for the information. Could you please share sample code to demonstrate what API you are calling to generated signed URL using S3 and CloudFront?

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 This is a standard priority issue labels Dec 15, 2023
@SonalCalcey
Copy link
Author

@ashishdhingra These are the sample codes that we used to generate signed URL.

S3
s3-sample-code


CloudFront
cloudfront - code

Thanks,
Sonal

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 17, 2023
@SonalCalcey
Copy link
Author

SonalCalcey commented Jan 1, 2024

Hi @ashishdhingra,

Just to Make sure that you understand the issue we have done a direct benchmark between CloudFront and S3. With the results of the below benchmarks, our main concern is that compared to the S3 signed URL generation time, why the CloudFront signed URL generation time is higher.

Is this behavior normal or are there any other methods or ways to get the CloudFront Signed URL without performance degradation that we are unaware of?

Benchmark result:

cloud_and_s3_performance


Code used for the benchmark:

[MemoryDiagnoser]
public class CloudFrontRunner
{
	// CloudFront 
	private static string _sourceKey;
	private static string _cloudFrontKeyId;
	private static string _cloudFrontPrivateKey;
	private static string _cloudFrontDistributionDomain;

	// S3
	private static string _accessKeyId;
	private static string _secretAccessKey;
	private static string _bucketName;
	private static AmazonS3Client _s3Client;

	[GlobalSetup]
	public void GlobalSetup()
	{
		var configuration = new ConfigurationBuilder()
			.AddJsonFile("appsettings.json", optional: false)
			.Build();

		_sourceKey = configuration["AWS:SourceKey"]!;

		// CloudFront
		_cloudFrontKeyId = configuration["CloudFront:KeyPairId"]!;
		_cloudFrontPrivateKey = configuration["CloudFront:PrivateKey"]!;
		_cloudFrontDistributionDomain = configuration["CloudFront:DistributionName"]!;

		// S3
		_accessKeyId = configuration["AWS:AccessKeyId"]!;
		_secretAccessKey = configuration["AWS:SecretAccessKey"]!;
		_bucketName = configuration["AWS:BucketName"]!;
		_sourceKey = configuration["AWS:SourceKey"]!;
		_s3Client = new AmazonS3Client(_accessKeyId, _secretAccessKey, RegionEndpoint.APSoutheast1);
	}

	[GlobalCleanup]
	public void GlobalCleanup()
	{
		_s3Client.Dispose();
	}

	[Benchmark]
	public string CloudFrontGenerateSignedUrl()
	{
		return AmazonCloudFrontUrlSigner.GetCannedSignedURL(
			AmazonCloudFrontUrlSigner.Protocol.https,
			_cloudFrontDistributionDomain,
			new StringReader(_cloudFrontPrivateKey),
			_sourceKey,
			_cloudFrontKeyId,
			DateTime.Now.AddMinutes(5)
		);
	}

	[Benchmark]
	public string S3GenerateSignedUrl()
	{
		GetPreSignedUrlRequest request = new()
		{
			BucketName = _bucketName,
			Key = _sourceKey,
			Expires = DateTime.Now.AddMinutes(5)
		};

		return _s3Client.GetPreSignedURL(request);
	}
}

Versions:

AWSSDK.Core - 3.7.300.28
AWSSDK.CloudFront - 3.7.301.21
AWSSDK.S3 - 3.7.305.3
.Net - 7

Thanks,
Sonal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sdk-custom needs-investigation p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants