emgarten / Sleet

A static nuget feed generator for Azure Storage, AWS S3, and more.
MIT License
362 stars 43 forks source link

Set a timeout value for the AmazonS3Client #163

Closed rmt2021 closed 2 years ago

rmt2021 commented 2 years ago

I found this in the AWS S3 document https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/retries-timeouts.html:

The AWS SDK for .NET enables you to configure the request timeout and socket read/write timeout values at the service client level. These values are specified in the Timeout and the ReadWriteTimeout properties of the abstract Amazon.Runtime.ClientConfig class. These values are passed on as the Timeout and ReadWriteTimeout properties of the HttpWebRequest objects created by the AWS service client object. By default, the Timeout value is 100 seconds and the ReadWriteTimeout value is 300 seconds... The versions of the AWS SDK for .NET that target the portable class library (PCL) and .NET Core set Timeout to the maximum value for all AmazonS3Client and AmazonGlacierClient objects.

So the AWS SDK will set the largest integer as the timeout by default. Currently, we will always wait for the response to come, which will make the SDK API unresponsive and decrease the efficiency. Even worse, if the response is lost during its delivery, we will wait there forever. In this regard, I manually set the timeout of AmazonS3Client as 10 seconds.

emgarten commented 2 years ago

Good catch on the SDK, these calls need to timeout.

I'm worried that 10 seconds will be too low for someone running this from a slow network.

When running within the same AWS region 10 seconds should be more than enough.

Let's try to find a balance on this. How about setting it to 100 (similar to .NET desktop) and/or making the timeout a config value so it can be adjusted if needed?

rmt2021 commented 2 years ago

Thanks for the suggestion @emgarten ! I think it makes a lot of sense.

I have enlarged the timeout to 100 seconds.

emgarten commented 2 years ago

Released in https://www.nuget.org/packages/Sleet/5.0.14