8

This is a dummy question. I have to give public access to PDFs, let's say 8 MB / file. It seems to me that nginx will serve any kind of files, as long as they are static. But someone tells me nginx isn't suited for this.

Can you provide me some documentation to prove me/him wrong ?

voretaq7
  • 79,345
  • 17
  • 128
  • 213
Elvex
  • 217
  • 2
  • 9
  • 2
    I can't think of any web server that *couldn't* do a good job of serving mid-sized static files. Out of curiosity, what would they suggest be used instead? – Shish Feb 07 '12 at 13:12
  • Whenever I see a question like this I can only wonder why you didn't just try it. Surely that would have been much quicker than posting the question and waiting for answers. – John Gardeniers Feb 10 '12 at 08:05

3 Answers3

23

There is nothing to prove, nginx is specifically optimized for serving static content.

You were told wrong.

pauska
  • 19,532
  • 4
  • 55
  • 75
14

The typical use for nginx is to serve the static files for a web site, while something else (which nginx proxies to) serves the dynamic content. Unless you're generating the PDFs on the fly, nginx should be perfectly fine.

cjc
  • 24,533
  • 2
  • 49
  • 69
2

When in doubt, benchmark! Fortunately someone else has already done this:

http://nbonvin.wordpress.com/2011/03/24/serving-small-static-files-which-server-to-use/

Conclusion? Allow me to quote:

G-WAN seems again to perform a lot better than the other servers. Nginx always performs slightly better than Lighttpd, while Apache Traffic server is very similar to Lighttpd in term of performance.

And:

Regarding the resources used by each server, Nginx is the winner in term of memory usage, as the amount of memory does not increases with the number of concurrent clients. G-WAN requires 2 times less CPU than the other servers.

The proof is in the numbers. Nginx is second best at requests/second, average for cpu usage, and best for memory usage. So yes, nginx is definitely a good server for statically serving standard size PDFS.

Ben Lee
  • 626
  • 2
  • 9
  • 23
  • 2
    "Except running G-WAN with root priviledges, nothing has to be done to further optimize the performance". This - is why you don't look at benchmarks to decide what works best for you. You set up the software in your own environment, and do your own tests to see what fits the best. – pauska Feb 10 '12 at 07:47
  • 1
    I agree that personal benchmarks are better than trusting other sources (though I haven't done any benchmarks myself -- I use nginx to serve apps and static files and it works fine for my servers so I have no reason to switch or benchmark). But I don't see how looking at another benchmark is worse than just making a blanket assertion or assumption? – Ben Lee Feb 10 '12 at 17:56
  • If you find the source unsatisfying, and don't have the time/inclination to do your own benchmark, you can always look for another. – Ben Lee Feb 10 '12 at 17:58
  • There is plenty of information on this. Here's another one I just found on google: http://www.ruby-forum.com/topic/150120, and it further has links to others. My point isn't about the specific benchmark. My point is, when you don't know something about performance, *use benchmarks*, even if they are not your own. The one I put in my answer was just an example, but the other results I'm finding online all tend to be in line with this one that nginx is near the top for request/second and memory usage. – Ben Lee Feb 10 '12 at 18:00
  • And @pauska, did you downvote this? I just noticed a downvote on it. The benchmark I used as an example was perfectly clear about what configuration it did for all servers, and was not sneaky about anything, so you can draw legitimate conclusions from it. The only real optimization for nginx it made was aligning the number of workers to the number of cores. I find the configuration choices the author made pretty acceptable for good comparison metrics. – Ben Lee Feb 10 '12 at 18:04