Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Amazon S3 have a connection pool?

Tags:

I ever used the code

public static AmazonS3Client s3 = null; ... BasicAWSCredentials c = new BasicAWSCredentials("absadgwslkjlsdjgflwa"); s3 =  new AmazonS3Client(c); 

Only one instance s3 is created while dozens of threads will upload images by s3.putObject(). In the dump info, I could see that one thread would lock the only instance s3 while the others were waiting.

So I think maybe it will be faster if I use the code below:

BasicAWSCredentials c = new BasicAWSCredentials("absadgwslkjlsdjgflwa"); for(int i = 0; i < 10; i++)     amazonS3[i] = new AmazonS3Client(c); 

Everytime the system will get a random s3 instance and then upload the image.

private static AmazonS3 getS3(){     int i = (int)(Math.random() * 10);      return amazonS3[i]; } 

But it seems that the system slow down. Why that happened? Maybe the only instance s3 has already used connection pool? I am confused.

like image 321
Mark_H Avatar asked May 03 '13 08:05

Mark_H


People also ask

Is AWS S3 connected to an availability zone?

Objects stored in the S3 One Zone-IA storage class are stored redundantly within a single Availability Zone in the AWS Region you select. For S3 on Outposts, your data is stored in your Outpost on-premises environment, unless you manually choose to transfer it to an AWS Region.

What is S3 connectivity?

Amazon S3 (Amazon Simple Storage Service) is a service that is offered by Amazon Web Services (AWS) that provides object storage through a web service interface. For other types of S3-compliant connections, you can use the Generic S3 connection.

Is S3 a global service?

Amazon S3 supports global buckets, which means that each bucket name must be unique across all AWS accounts in all the AWS Regions within a partition. A partition is a grouping of Regions.


1 Answers

Each client in the AWS SDK for Java (including the Amazon S3 client) currently maintains it's own HTTP connection pool. You can tune the maximum size of the HTTP connection pool through the ClientConfiguration class that can be passed into client object constructors.

We recommend sharing client objects, because of the expense and overhead of having too many HTTP connection pools that aren't being utilized effectively. You should see better performance when you share client objects across threads like this.

like image 178
Jason Fulghum Avatar answered Oct 03 '22 22:10

Jason Fulghum