Live data from Hacker News

Nginx: a caching, thumbnailing, reverse proxying image server

charlesleifer.com

41–50 of 59 posts

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#41

Earlier quoted context omitted.

Well without some sort of caching, his site very well could fall over when being on the front page of something like HN. Putting Varnish in front a site, even with something simple like a 1 minute cache on everything, makes you pretty much immune from having "large amounts of traffic" being a real problem.

Exactly, thanks frank! :P

By removing varnish aren't you now exposed to that risk once again?

I feel like I am missing something.

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#42
post #39

Earlier quoted context omitted.

If all you need is crop or resize, might as well use nginx in my opinion.

There was one annoyance we have to fix that I don't think the nginx module supports & that's rotating images based on their exif orientation (mobile devices love to upload landscape images w/ an exif-orientation in portrait). Python is definitely an OK solution for this as it turns out. We resize a few million of images a day on-demand on two n1-highcpu-8 GCE instances. Although, they could easily be a fourth the siz…

That's a good point. The nginx module can rotate, but I don't know of any built-in support for rotation with respect to exif. You could also use lua and the lua imagemagick bindings and probably see much better performance though.

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#43
post #40

I wrote a similar article a few years back that employs Lua and imagemagick bindings: http://leafo.net/posts/creating_an_image_server.html

Yeah, I'm pretty sure I linked to your post. I was going to use your script before I realized I could do everything with plain old nginx.

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#44
post #3

If you use a CDN such as Cloudflare, you can do a similar trick but forget about the proxy cache (and associated storage needs) - as long as every image at every size gets a unique URL and you control http cache headers correctly, Cloudflare will store copies of every image size ever requested across their CDN network. In terms of this blog post, you'll only need the "resizing server". This is a very simple and state…

That's not quite true. Cloudflare (like virtually every CDN) only caches files at the edge server that handled the request. And they purge the files after a short period of time--even if your cache-control headers ask for a longer time. Most won't tell you how short (including Cloudflare), but some CDNs will delete files after as little as two hours.. 24 hours is very common. Most CDNs also give you no visibility abo…

Might want to throw a disclaimer on the end there?

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#45
A few years ago everyone was jumping on nginx saying it's the 2nd coming of Jesus and that being a simple web server without dynamic config or modules to do processing made it better than Apache because it's "fast".

How many of those same people are now going on about how nginx has finally got some support for loadable modules and built in processing like this?

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#47

A few years ago everyone was jumping on nginx saying it's the 2nd coming of Jesus and that being a simple web server without dynamic config or modules to do processing made it better than Apache because it's "fast". How many of those same people are now going on about how nginx has finally got some support for loadable modules and built in processing like this?

I like nginx because its config is about fourteen times easier to follow than apache's.

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#48

Earlier quoted context omitted.

Exactly, thanks frank! :P

By removing varnish aren't you now exposed to that risk once again? I feel like I am missing something.

He would have been if it hadn't replaced the Varnish functionality with nginx.

He's basically just moving functionality from Varnish to nginx and thus simplifying his stack a bit.

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#49

Earlier quoted context omitted.

Exactly, thanks frank! :P

By removing varnish aren't you now exposed to that risk once again? I feel like I am missing something.

Nginx can cache static content of any type, so it can act as varnish for both his blog content and images and resize them on the fly instead of relying on multiple image sizes on disk or a separate app to serve images. Nginx is a highly efficient webserver when it is already holding the items in cache (and otherwise, it passes off dynamic content just fine but that is then up to the underlying application to perform as well).

Re: Nginx: a caching, thumbnailing, reverse proxying image server

#50
Could someone here explain to me how it's possible that a bug like [1] concerning the main functionality of nginx (static file routing) is open since many years, and yet nginx keeps its popularity? Is that really the best we've got?

[1] https://trac.nginx.org/nginx/ticket/97

Post reply on HN