Edward Snowden
Edward Snowden

Reputation: 155

Amazon s3 vs Ec2 Storing Files

Which one is better for storing pictures and videos uploaded by user ?

Amazon s3 or Filesystem EC2 ?

Upvotes: 5

Views: 4139

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270074

While opinion-based questions are discouraged on StackOverflow, and answers always depend upon the particular situation, it is highly likely that Amazon S3 is your better choice.

You didn't say whether only wish to store the data, or whether you also wish to serve the data out to users. I'll assume both.

Benefits of using Amazon S3 to store static assets such as pictures and videos:

  • S3 is pay-as-you-go (only pay for the storage consumed, with different options depending upon how often/fast you wish to retrieve the objects)
  • S3 is highly available: You don't need to run any servers
  • S3 is highly durable: Your data is duplicated across three data centres, so it is more resilient to failure
  • S3 is highly scalable: It can handle massive volumes of requests. If you served content from Amazon EC2, you'd have to scale-out to meet requests
  • S3 has in-built security at the object, bucket and user level.

Basically, Amazon S3 is a fully-managed storage service that can serve static assets out to the Internet.

If you were to store data on an Amazon EC2 instance, and serve the content from the EC2 instance:

  • You would need to pre-provision storage using Amazon EBS volumes (and you pay for the entire volume even if it isn't all used)
  • You would need to Snapshot the EBS volumes to improve durability (EBS Snapshots are stored in Amazon S3, replicated between data centres)
  • You would need to scale your EC2 instances (make them bigger, or add more) to handle the workload
  • You would need to replicate data between instances if you are running multiple EC2 instances to meet request volumes
  • You would need to install and configure the software on the EC2 instance(s) to manage security, content serving, monitoring, etc.

The only benefit of storing this static data directly on an Amazon EC2 instance rather than Amazon S3 is that it is immediately accessible to software running on the instance. This makes the code simpler and access faster.

There is also the option of using Amazon Elastic File System (EFS), which is NAS-like storage. You can mount an EFS volume simultaneously on multiple EC2 instances. Data is replicated between multiple Availability Zones. It is charged on a pay-as-you-go basis. However, it is only the storage layer - you'd still need to use Amazon EC2 instance(s) to serve the content to the Internet.

Upvotes: 15

Related Questions