Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (12.9k points)

We need to serve the same image in a number of possible sizes in our app. The library consists of 10's of thousands of images which will be stored on S3, so storing the same image in all it's possible sizes does not seem ideal. I have seen a few mentions on Google that EC2 could be used to resize S3 images on the fly, but I am struggling to find more information. Could anyone please point me in the direction of some more info or ideally, some code samples?

Tip

It was not obvious to us at first, but never serve images to an app or website directly from S3, it is highly recommended to use CloudFront. There are 3 reasons:

  • Cost - CloudFront is cheaper
  • Performance - CloudFront is faster
  • Reliability - S3 will occasionally not serve a resource when queried frequently i.e. more than 10-20 times a second. This took us ages to debug as resources would randomly not be available.

The above are not necessarily failings of S3 as it's meant to be a storage and not a content delivery service.

1 Answer

0 votes
by (18.2k points)

Considering the use case mentioned in your question, I think there is a better approach to achieve what you want. How about your store all image sizes? This way you will be able to serve your images up through CloudFront or directly from S3 and then you won't have to rely on your application server to modify the image size on the fly. This will significantly help save the processing cost.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...