Should I persist images on EBS or S3?

5,667

Solution 1

In regard to costs, it is not necessarily true that S3 will cost more than EBS. If you have a 15 GB EBS volume, you pay for all that storage whether it contains 1 GB of data or even no data yet. With S3, you only pay for the actual data stored.

Your strategy should be to use EBS for the mounted volume but to always back EBS up to S3. In the past there was a way to use S3 plus cache for the mounted volume (called PersistentFS) but it is defunct now. So mount an EBS volume and then back it up to S3.

Here are some facts to back up that recommendation as well as a general comparision of EBS and S3:

  • EBS can only be used with EC2 instances while S3 can also be used outside EC2
  • EBS appears as a mountable volume while the S3 requires software to read and write data
  • EBS can accommodate a smaller amount of data than S3
  • EBS can only be used by one EC2 instance at a time while S3 can be used by multiple instances
  • S3 typically experiences write delays while EBS does not
  • S3 is redundant (6 copies I think) while EBS is not. http://www-differencebetween.net/technology/internet/difference-between-amazon-s3-and-amazon-ebs/

  • In terms of performance S3 has the higher latency and also has higher variation in latency. S3 write latency can also be higher than read latency . EBS on the other hand has lower latency with less variation. It also has writeback caching for very low write latency. http://www-cloudiquity.com/2009/03/differences-between-s3-and-ebs/

  • EBS (with 20 GB of modified data) has an expected annual failure rate of 0.1% to 0.5%.

  • With EBS, you pay $0.10 per GB per month for the size of the volume, whether you have stored any data on that volume or not.
  • With S3 you pay $0.15 per GB per month for snapshots -- ONLY FOR DATA ACTUALLY STORED.

  • The reliability of EBS depends on maintaining recent snapshots. As described by Amazon at http://www-amazon.com/b/ref=sc_fe_c_0_201590011_1?node=689343011 , the reliability of EBS depends the amount of data stored on the volume that has not been backed up to S3 using a snapshot. Therefore, to achieve durability with EBS, it is important to keep the data on the volume backed up to S3 by taking frequent snapshots.

  • You will be paying both $0.10 per GB per month for the size of the EBS volume, plus $0.15 per GB per month for the S3 snapshots. But multiple snapshots are stored incrementally. If you have a device with 100 GBs of data, but only 5 GBs of data has changed since your last snapshot, only the 5 additional GBs of snapshot data will be stored back to Amazon S3. http://aws.amazon.com/ebs/

Solution 2

  1. Costs: Keeping images on S3 will cost you more especially if you use CloudFront. Amazon charges for both traffic and GET/PUT requests and cost of GET/PUT requests may be even higher than traffic costs for small files.

  2. What is safer? S3 is really a safer storage than EBS according to Amazon, but i think it's not a big deal as you may easily backup EBS onto S3 periodically.

  3. API: S3 API is pretty simple and it's not a big problem to save a file onto S3.

  4. Security. It's safer to host user-uploaded files apart from the web application - harder to upload mallicious content onto your web application server for hackers.

  5. Speed. I don't think that EBS hosted files served by tomcat can be faster than files hosted on S3 especially when using CloudFrond (CDN).

Another option I'd recommend is to setup a separate lightweight web server (nginx works perfect for such tasks) to serve static content from EBS. This solution will be rather fast, secure (if served from a separate instance) and cost-effective.

Solution 3

Serving statics from EBS may influence my web server's performance negatively

Well, what is amount of your static data? If it's under 1Gb it is very likely to stick in cache, and therefore would not influence performance at all.

Solution 4

What is your traffic volume? Is it worth it to you to you use S3 as a Content Delivery Network or will you use regular S3?

How much more complicated will it be for you to use S3 rather than local storage on the drive with EBS? The static data delivery could be a factor depending your application.

Solution 5

If you will have some serious traffic & users you may want to go with S3 because it allows using as a CDN. You may have to consider costs if you are expecting a lot of user data. For S3 you have to pay per GET/PUT, so a lot of small files will cost you. With EBS on your EC2 image you will only pay for bandwidth.

I would suggest you run the numbers. Also see what is easier for your applicatino to do.

Share:
5,667

Related videos on Youtube

enesness
Author by

enesness

Entrepreneur & Developer @Upstash

Updated on September 18, 2022

Comments

  • enesness
    enesness over 1 year

    I am migrating my Java,Tomcat, MySQL server to AWS EC2.

    I have already attached an EBS volume for storing MySQL data. In my web application, people may upload images, which I should persist.

    There are two alternatives in my mind:

    1. Save uploaded images to the EBS volume.
    2. Use the S3 service.

    The followings are my notes, please be skeptical about them, as my expertise is not in servers, but in software development.

    • EBS plus: S3 storage is more expensive. (0.15 $/Gb > 0.1$/Gb)

    • S3 plus: Serving static files from EBS may influence my web server's performance negatively. Is this true? Does serving images affect a server performance notably? For S3, my server will not be responsible for serving static files.

    • S3 plus: Serving static files from EBS may result in I/O cost, though it will probably be minor.

    • EBS plus: People say EBS is faster.

    • S3 plus: People say S3 is safer for persistence.

    • EBS plus: There is no need to learn an API: it is straightforward to save the images to an EBS volume.

    I can not decide, and am asking for guidance.

  • enesness
    enesness about 14 years
    For now not so much traffic volume. About 10 Gb for month. But the product is new and free, I have not marketed it so I expect traffic gets higher. Indeed this is free e-shop web application, the users will upload their products' images to system. I have a look at S3 API, it is not complicated to use S3, if you say "Yes using S3 will be good for your web server, as it gets rid of serving statics." then I will decide on S3.
  • enesness
    enesness about 14 years
    App is new, data is under 1 Gb for now but expect and hope increases because it is free. Sorry, cache of what? Cache of web server?
  • BarsMonster
    BarsMonster about 14 years
    I mean "disk" cache, files loaded from anything are cached in memory. You may have 100Gb of static data, but if you have 0.5Gb of 'hot files' it will be fast.