0

I am developing a django application that allows users to upload photos and view them and these photos are stored as private in S3. Now everytime I have to show them the thumbnails, i generate a url and give it to the template. This process is really very slow and takes very long time. I am hoping there is some other way that i havent explored, please help me out. I was hoping for something like x-sendfile, where i authenticate the user and than redirect it to S3. Please let me know if I am missing out anything

Saransh Mohapatra
  • 9,430
  • 10
  • 39
  • 50
  • Am I right you're proxying private images via EC2 instance running Django? – mderk Feb 16 '13 at 20:21
  • Yeah....i m not proxying, just generating urls. But i think proxying would be a better option. Please let me know – Saransh Mohapatra Feb 16 '13 at 20:23
  • You mean, you generating temporary authenticated urls to S3? Seems to me the best solution so far... – mderk Feb 16 '13 at 20:36
  • yeah...but it's very hectic as generating so many urls everytime is really not good principle. – Saransh Mohapatra Feb 16 '13 at 21:31
  • I'm doing something similar and I haven't had any performance issues creating the [pre-signed URLS with boto](http://boto.readthedocs.org/en/latest/ref/s3.html#boto.s3.bucket.Bucket.generate_url). Are you sure this is where the performance overhead is coming from? – Roarster Feb 17 '13 at 08:08
  • Right now i on my development server and i think that might be the reason. But you are sure that its not that slow ?? – Saransh Mohapatra Feb 17 '13 at 08:33
  • I can't test just now but I think generating a URL takes less than a 10th of a second per image. Certainly while debugging it feels instantaneous. What sort of performance are you seeing? – Roarster Feb 17 '13 at 09:05
  • Not i m right now seeing very slow creation of signed urls. But the reason may be that my localhost has to send request to S3 to create the urls. But I m anticipating a bit less time when the server will be located in EC2-same region as S3. So I want to know is my anticipation correct?? And is there any other good alternative. – Saransh Mohapatra Feb 17 '13 at 10:43

2 Answers2

3

I forked sorl-thumbnail to make it fast with S3. My code is here sorl_thumbnail-async

But I came to know easy_thumbnails does exactly what I was trying to do, so I am using it in my current project. Sorl is not updated since last year, use easy_thumbnails with remote storages like S3. You might find useful my post on the topic here

[Edit]: sorl-thumbnail now has new maintainers and is updated with latest django releases.

chhantyal
  • 11,874
  • 7
  • 51
  • 77
1

You can use sorl-thumbnail to serve thumbnails with pluggable S3 backend support and memcached or redis for caching.

You might find this question helpful: Storing images and thumbnails on s3 in django

Community
  • 1
  • 1
almalki
  • 4,595
  • 26
  • 30