Is it cheaper to store resized images on s3 or is it cheaper to use lambda edge with cloudfront to resize the image on each request?

0

I've built a social media app that lets people upload profile images among other things. These profile images need to be served in both the original format as well as a smaller thumbnail format.

Right now i'm storing a resized thumbnail version of the original image, which costs more money then simply storing the original image only. I could choose to not store the thumbnail version and have it created by a AWS lambda whenever the resized image is requested from a certain endpoint. But running the lambda function over and over again to resize images costs money too.

So which approach would be cheaper? Resizing the thumbnail image once and store it on s3 or creating a resized version of the original image on demand?

2 Answers
1
Accepted Answer

Hi, The AWS Pricing Calculator (calculator.aws) is a great tool for estimating costs. I recommend you work out the total cost for either approach to see how they compare. However, storage on S3 is pretty cheap (about $0.02/GB/month) so you'll probably find that the cost is negligible.

Another big factor you'll want to consider is latency i.e. how long it takes for the profile picture to be sent once the user requests it. Resizing the image each time it was requested will inevitably increase the latency, but you'll have to experiment to whether this is a big impact.

Either approach would probably be fine but personally I'd recommend resizing the thumbnail images once and then storing this in S3. I imagine that on your social media site each thumbnail is viewed many times and so only processing it once and then storing the result is likely to come out cheaper. However, again the cost is likely to be negligible and so the latency advantage of processing the images before the user asks is also worth considering.

Thanks,

Marrick.

Marrick
answered 2 years ago
profile picture
EXPERT
reviewed 17 days ago
1

The answer really depends on the actual usage. If the resized image is not accessed very often, than maybe calculating each time will be cheaper. If it is accessed more frequently, calculating it once and saving it will be cheaper. Usually I think that calculating it upfront and saving in S3 is the preferred option, also from latency point of view.

profile pictureAWS
EXPERT
Uri
answered 2 years ago
profile picture
EXPERT
reviewed 17 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions