Django的+ S3(博托)+ SORL缩略图:优化的对策建议 [英] Django + S3 (boto) + Sorl Thumbnail: Suggestions for optimisation

查看:545
本文介绍了Django的+ S3(博托)+ SORL缩略图:优化的对策建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的S3存储后端跨Django的网站我发展,既减轻负载从EC2服务器上,并允许多个Web服务器(冗余,负载均衡)访问同一组上传的媒体。

I am using S3 storage backend across a Django site I am developing, both to reduce load from the EC2 server(s), and to allow multiple webservers (redundancy, load balancing) access the same set of uploaded media.

Sorl.thumbnail(V11)的模板标签被用在我们的模板,允许灵活的图像缩放/裁剪。

Sorl.thumbnail (v11) template tags are being used in our templates to allow flexible image resizing/cropping.

在富媒体页面的性能不是很好,并且使用了一个包含缩略图需要在第一次被生成的页面时,请求甚至超时。

Performance on media-rich pages is not very good, and when a page containing thumbnails needing to be generated for the first time is accessed, the requests even time out.

据我所知,这是由于SORL缩略图检测/下载从S3原始图像(这可能是相当大,分辨率高),和渲染/检查/上传的缩略图。

I understand that this is due to sorl thumbnail checking/downloading the original image from S3 (which could be quite large and high resolution), and rendering/checking/uploading the thumbnail.

你会怎么建议是这样设置的最佳解决方案?

What would you suggest is the best solution to this setup?

我已经看到存储文件的本地副本,除了S3副本的建议(不是伟大的,当被用于负载平衡的一对夫妇服务器)。此外,我已经看到了它提出来存储0字节文件来糊弄sorl.thumbnail。

I have seen suggestions of storing a local copy of files in addition to the S3 copy (not to great when a couple of server are being used for load balancing). Also I've seen it suggested to store 0-byte files to fool sorl.thumbnail.

是否有任何其他建议或接近这个更好的方法?

Are there any other suggestions or better ways of approaching this?

推荐答案

SORL缩略图现在与远程慢储量而创建的。缩略图的首创不过是做quering存储,例如首先从模板访问,但在这之后的引用缓存在键值存储。不过您需要的第一个查询和创作,以及一种解决方案是使用低级别的API sorl.thumbnail.get_thumbnail使用相同的选项时,图像上载。当图像上传添加此缩略图创造就业机会如芹菜一阙。

sorl thumbnail is now created with remote slow storages in mind. The first creation of the thumbnail is however done quering the storage, for example first accessed from template, but after that the references are cached in a key value store. Still you need the first query and creation, well one solution is to use the low level api sorl.thumbnail.get_thumbnail with the same options when the image is uploaded. When the image uploaded add this thumbnail creation job to a que like celery.

这篇关于Django的+ S3(博托)+ SORL缩略图:优化的对策建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆