Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload direct to S3 or via EC2?

I would like to build a web service for an iPhone app. As for file uploads, I'm wondering what the standard procedure and most cost-effective solution is. As far as I can see, there are two possibilities:

  1. Client > S3: I upload a file from the iPhone to S3 directly (with the AWS SDK)
  2. Client > EC2 > S3: I upload a file to my server (EC2 running Django) and then the server uploads the file to S3 (as detailed in this post)

I'm not planning on modifying the file in any way. I only need to tell the database to add an entry. So if I were to upload a file Client > S3, I'd need to connect to the server anyways in order to do the database entry.

It seems as if EC2 > S3 doesn't cost anything as long as the two are in the same region.

I'd be interested to hear what the advantages and disadvantages are before I start implementing file uploads.

like image 561
n.evermind Avatar asked Feb 19 '12 10:02

n.evermind


People also ask

How do I upload data to AWS S3?

To upload folders and files to an S3 bucketSign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.

What is difference between EC2 and S3?

Amazon EC2 and Amazon S3 are fundamentally different types of services. One allows you to run servers in the cloud with minimal effort on your part, while the other is designed for storing large amounts of static data and ideal for data backups.

What is S3 direct upload?

Amazon S3 Direct Upload for Web UI is an addon that allows Web UI to make use of S3 Direct Upload to directly upload files to a transient bucket, which will then be moved by the Nuxeo server to a final bucket once the upload is finished.


1 Answers

I would definitely do it through S3 for scalability reasons. True, data between S3 and EC2 is fast and cheap, but uploads are long running, not like normal web requests. Therefore you may saturate the NIC on your EC2 instance.

Rather, return a GUID to the client, upload to S3 with the key set to the GUID and Content-Type set appropriately. Then call a web service/Ajax endpoint to create a DB record with the GUID key after the upload completes.

like image 93
reach4thelasers Avatar answered Sep 23 '22 13:09

reach4thelasers