TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Nginx image processing server with OpenResty and Lua

106 点作者 fcambus超过 11 年前

11 条评论

danielrhodes超过 11 年前
I have done something similar at a little scale. At small load, it is great. The larger you get, real problems start to arise.<p>The bottleneck with this implementation is ImageMagick. ImageMagick leaks a lot of memory and is generally very inefficient with resizing operations. GraphicsMagick is not much better. Under high load, this will crush your CPUs and max out your Nginx threads much faster than it is worth. You will almost definitely need to use something like OpenCV on the GPU for this to scale.<p>Although caching is referenced briefly in this article, it is crucial for this system to work. A good CDN with fast invalidation and a low eviction rate would be ideal.
评论 #6421316 未加载
评论 #6420916 未加载
评论 #6420958 未加载
评论 #6421460 未加载
staunch超过 11 年前
I&#x27;ve probably done this ten times in ten different ways over the years. Most recently with ~150 lines of Go via nginx proxy_pass (or fastcgi_pass). I needed to be able to control how to resize images while maintaining aspect ratio on a fixed size canvas. The first request for an image is disappointingly slow for larger images, but it&#x27;s not terrible. Writing out the generated images to a cache directory and using try_files, so subsequent requests are static, is definitely key.
评论 #6420035 未加载
ck2超过 11 年前
Did it with the perl module in Nginx with imagemagick.<p>Much more powerful than their built in image handling which uses the ancient and no longer updated GD library.
评论 #6420059 未加载
评论 #6419460 未加载
tt超过 11 年前
I highly recommend <a href="http://www.imgix.com/" rel="nofollow">http:&#x2F;&#x2F;www.imgix.com&#x2F;</a>
juri超过 11 年前
I can recommend thumbor: <a href="https://github.com/globocom/thumbor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;globocom&#x2F;thumbor</a>
lamnk超过 11 年前
Since disk space is not much of problem this day, why don&#x27;t we just pre-process the images? I know this only applies if you know in advance which sizes you want, but do you really need like 20 different sizes of an image?
评论 #6433604 未加载
zzzcpan超过 11 年前
Since author is talking about security a bit, I&#x27;ll add. Be careful, if there is a bug somewhere in imagemagick or it runs out of memory, it could easily take down an entire worker process and abort every connection there.
评论 #6420189 未加载
评论 #6419863 未加载
tmzt超过 11 年前
Has anybody done something like this with support for uploading and resizing images via a REST API with OpenResty. Do you know of any good examples or tutorials for that or upload support in general?
the1超过 11 年前
for true hipster web scale power, one must use node.js <a href="https://github.com/saml/nodejs-resize-image" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;saml&#x2F;nodejs-resize-image</a>
评论 #6421705 未加载
canterburry超过 11 年前
...or you could just use Pixtulate (<a href="http://www.pixtulate.com" rel="nofollow">http:&#x2F;&#x2F;www.pixtulate.com</a>)
评论 #6420457 未加载
limmeau超过 11 年前
Thanks for posting this. Do those Lua scripts run concurrently in any way?
评论 #6419740 未加载