moeseth
moeseth

Reputation: 1945

EC2 and S3 image server

I'm creating an image upload service using EC2 and S3.

User uploads image to EC2 using PHP. EC2 uploads to S3 and then EC2 responds to user with the image link.

I was wondering how fast the upload between EC2 and S3 in the same region is.

Would it be better to store image temporarily on EC2, responds to user first and upload to S3 later or wait for the upload to finish before responding to user?

Upvotes: 0

Views: 109

Answers (2)

Michael - sqlbot
Michael - sqlbot

Reputation: 178966

I was wondering how fast the upload between EC2 and S3 in the same region is

It's fast. Test it.

You should find that you can upload the image to S3 very quickly, then return the S3 URL to the client, where they'll immediately be able to fetch the image.

Caveat: if you are overwriting an S3 object at the same path, rather than creating a new object, there can be a delay after the time you upload the object before the new object is consistently returned for every request. This delay is unlikely, but possible, due to the eventual consistency model of S3. Deletes are the same way -- a deleted object may be still fetchable, briefly, before requests to S3 return 404 or 403.

See What is maximum Amazon S3 replication time on file upload? and note the change you should make to the endpoint if you're working in the US Standard (us-east-1) region to ensure immediate consistency.

Upvotes: 3

E.J. Brennan
E.J. Brennan

Reputation: 46839

It will be plenty fast; the latency between the user and your ec2 instance will be much bigger than the latency between ec2 and s3.

On the otherhand, if ec2 is not doing anything to the image before uploading it to s3, why not upload it directly to s3?

Upvotes: 1

Related Questions