0

I just wanted to ask if there was a speedy of dynamically showing thumbnails of images uploaded on S3. Lets say profile pictures.

I have 3 sizes of these pictures being shown Actual, 150x150 and 25x25. At the moment I am dynamically resizing them on the fly on my server - not S3.

http://www.mydomain.com/images/25X25/image.jpg

Above is a URL that checks if a thumbnail exists and if not generates it. I allow only 3 sizes at the moment.

Soon we would be shifting to S3. Is such thing possible at S3 also - do I have to get the original image, resize it and then reupload on S3 - all on the fly - of course with cache enabled?

Or should I do this when I upload the actual image itself - make 2 more thumbnails (with easily readable filename lile image_25_25 and image_150_150) and upload those too along with it?

So eventually every upload results in

https://bucket.s3.amazonaws.com/image.jpg
https://bucket.s3.amazonaws.com/image_25_25.jpg
https://bucket.s3.amazonaws.com/image_150_150.jpg

Which do you think is a good option? Or Suggestions please - will be really thankfull to you all (err - always am - such an amazing place this is to get help!)

Cheers!

4

1 回答 1

2

我认为您的方法在很大程度上取决于您进行此更改的主要目标是什么,您希望处理什么样的上传量,这些缩略图上的典型点击率是多少,以及您对成本的限制是什么执行此缩略图(即执行处理所需的服务器资源和存储成本)。

如果#1 最重要的事情是加快最终用户的图像下载时间,而不考虑成本,那么在上传时构建缩略图可能是最佳选择(可能与在 S3 存储桶前使用 Cloudfront 一起使用) . 这也将使您的应用程序无法尝试动态地为这些图像的请求提供服务。一个缺点显然是最终用户的上传过程可能需要更长的时间(如果您需要在向最终用户指示成功之前在 S3 中创建和可用的文件),当然您最终不得不占用服务器资源和每个上传图像的存储空间,无论该图像是否会被使用。

如果您更关心使用最少的资源和存储量,那么您可以继续采用使用 Web 应用程序处理图像请求并在 S3 中根据需要创建图像的方法。您可能会使用 s3fs 之类的东西(打开其缓存功能)来使这些图像在您的应用程序服务器的本地安装上可用,以帮助加快进程,但如果您的整体目标是提供最佳的用户体验(即最快的下载)。

于 2013-01-14T20:53:07.527 回答