I have read here that the Unicorn/Gunicorn HTTP server is 'not very good at serving static files', and that Nginx is better at serving static content. Can someone explain why this is?
I understand the specialised roles of Nginx and Gunicorn, and that Nginx is a reverse proxy, and that Gunicorn can actually serve static files if necessary.
Primarily because Unicorn was not designed to solve the suite of problems involved in serving files to clients:
Unicorn is a server for fast clients and Unix. What is a fast client? A fast client is another application or server that can interface with the Rack server quickly, without much latency. Unicorn is not good as a standalone server: it wasn’t designed to handle slow requests that occur over network connections. It relies on Nginx or Apache to handle the buffering and queuing of web requests so that it doesn’t have to worry about concurrency and event-driven programming. Unicorn is basically the glue between nginx and rack, where Nginx is the fast client.
Consider a case where you have 100 visitors on 56k modems trying to view a 400mb video. You really don't want to have to hold 100 instances of your application in memory, or load the file into memory, etc. Nginx was designed with this type of scenario in mind.