0

I'm setting up Amazon S3 to use as my media server for serving image files. I use easy_thumbnails for thumbnailing the images. easy_thumbnails does the cropping before sending them to S3, therefore storing 4 images with each a different size. Without Amazon S3, the page does 2 queries to load the page. With Amazon S3 it uses 6 queries for the same page. The queries show that the original file is queried as well as the cropped file. This shouldn't be necessary I believe. How can I decrease the amount of requests it does using S3?

This image shows the queries with Amazon S3 This image shows the queries with Amazon S3 This image shows the queries normally This image shows the queries without Amazon S3

**edit I noticed easy_thumbnails is not optimized for remote storages according to django packages. So, an alternative for easy_thumbnails that is optimized would help me as well!

Vincent
  • 1,494
  • 12
  • 26
  • It seems that your image is cropped before being sent to S3. If you look at the query you can see that the image is pre-processed before the call to AWS S3 storage. – Dos Feb 13 '19 at 09:11
  • @Dos True. the image is stored multiple times each with different sizes. Is that causing the problem? – Vincent Feb 13 '19 at 09:13
  • Yes, at least a query for each size, as the system needs to store and retrieve the image before sending it to S3. – Dos Feb 13 '19 at 09:17
  • @Dos is it possible to store just the original image at S3, just do a query for that file and do that cropping while loading the page or is that even worse for performance? – Vincent Feb 13 '19 at 09:19
  • I don't know how you're using easy_thumbnails, so I suggest you look at the settings docs in order to understand the best configuration for you. Here the link: https://easy-thumbnails.readthedocs.io/en/2.1/ref/settings/ – Dos Feb 13 '19 at 09:28

1 Answers1

0

It looks like easy_thumbnails requests the same image files everytime the page is loaded (caching that doesn't work for easy_thumbnails maybe). As I read that easy_thumbnails isn't optimized for remote storage I looked for alternatives and tried sorl-thumbnail. This seems to do the job! It doesn't send request each page load and therefore the amount of queries decreased a lot!

Vincent
  • 1,494
  • 12
  • 26