7

I am creating an iPhone app to allow users upload & share photos. Currently the photos uploaded are stored in my 1and1 cloud server I subscribed. Now I want to try AWS. I have subscribed a free tier AWS Linux EC2 and set up php/mysql. My question is, for scalability purpose, where should I store user pictures: EC2 or S3? And how to connect EC2 with S3 so user uploaded photos will be stored in S3? My understanding is that when user upload a photo to my EC2 instance, it is stored in EC2 and it will fill the space soon since I have only 5GB space.

With limited knowledge of AWS, my question may sound st**d but any help and advice will be appreciated!

100calorie
  • 305
  • 3
  • 4
  • 7

2 Answers2

7

You should store your pictures in S3, data stored within your EC2 instances are not persistent. Use AWS SDK to upload data to S3.

Michal Klouda
  • 14,263
  • 7
  • 53
  • 77
  • 2
    EC2 instances *are* persistent if you create them as EBS backed volumes, which you should almost always do. http://stackoverflow.com/a/3630707/141172 – Eric J. Aug 28 '12 at 02:37
  • Hi, Michael - Are you saying my app should directly call S3 iOS API to save photo in S3? I saw a post saying S3 is "eventual consistency" which means after a successful photo upload, the photo may not be immediately available for read. But the iPhone app does need read the photo from server to display on the screen right away. This way the iPhone app will interpret the upload as a "failure" and will try to upload again. – 100calorie Sep 10 '12 at 19:23
  • Eric - please check the following http://stackoverflow.com/questions/2288402/should-i-persist-images-on-ebs-or-s3 – 100calorie Sep 10 '12 at 19:43
  • Hi @100calorie, S3 provides read-after-write consistency in most of the regions (see [here](http://aws.amazon.com/s3/faqs/#What_data_consistency_model_does_Amazon_S3_employ)), so bear this in mind while picking the region for your buckets. – Michal Klouda Sep 10 '12 at 20:11
6

For this use case I would use S3.

The advantage of using S3 backing for your pictures is that you can easily use Amazon's Cloud Front CDN with S3 as the origin (you can also use your EC2 instance, but that involves more work).

And how to connect EC2 with S3 so user uploaded photos will be stored in S3

There is an S3 API for PHP

http://aws.amazon.com/sdkforphp/

Eric J.
  • 147,927
  • 63
  • 340
  • 553