Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django sorl thumbnail Crash - Lots of Large images

When ever I have lots of large images, like 800x650 etc in a template, Django just crashes. It works on my Mac locally but not on my Linode production server. Could one do sort of a batch process where it does a few, then stops then does a few again?

Im doing the thumbnailing in a {% for %} loop in my template, creating a small and a large image in each pass.

like image 620
Harry Avatar asked Dec 05 '25 10:12

Harry


1 Answers

I had the same thing going on as you do, I think. When a view is first accessed, sorl-thumbnail does it's thing, checking which thumbnails on the page need to be generated, and of course generating those that do. At the point of generating thumbnails, you're dropping to file I/O which is slow, like really slow compared to every other part of the web request.

If you have a ton of images, this can take quite a while (I saw upwards of 30 secs for the first load on some extremely image heavy pages). In my case, I was getting internal server errors; I'm not sure if that's the same as what you mean by "crashing". In reality, it's not really falling down, the problem is that the request timeout is usually set pretty low, I simply need to up my timeout to give the server longer to finish processing the request. It was still slow on first load, but after that, it's instantaneous and no more issues.

like image 140
Chris Pratt Avatar answered Dec 08 '25 00:12

Chris Pratt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!