Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it recommended to use AmazonS3Client as a singleton? [duplicate]

Is the Amazon .NET AWS SDK's AmazonS3 thread safe or should I be creating a new instance of AmazonS3 per request in a multi-threaded system?

Specifically for the latest .NET AWS SDK (version 1.3.14).

like image 912
InvertedAcceleration Avatar asked Oct 12 '11 16:10

InvertedAcceleration


People also ask

Should I dispose amazons3client?

My answer is YES you need to dispose it manually and I recommend keeping an instance of the object alive and re-using it for several operations just remember to dispose it when you are eventually done.

Is S3Client thread safe?

The namespace for a client class follows the convention Aws::Service::ServiceClient . For example, the client class for AWS Identity and Access Management (IAM) is Aws::IAM::IAMClient and the Amazon S3 client class is Aws::S3::S3Client . All client classes for all AWS services are thread-safe.


1 Answers

I also asked this question on the Amazon AWS forum and an official AWS employee replied (Norm@AWS) with:

The .NET SDK is thread safe so keeping an instance of any of the clients like AmazonS3 around and reusing them is fine.

Norm

Link (Amazon .NET Development Forum - Is the .NET SDK's AmazonS3 thread safe?).

like image 101
InvertedAcceleration Avatar answered Oct 24 '22 07:10

InvertedAcceleration