Why is Unicorn/Gunicorn slow to serve static content? [closed]

爷,独闯天下 提交于 2020-06-27 16:36:08

问题


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.


回答1:


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.

Source

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.



来源:https://stackoverflow.com/questions/42696229/why-is-unicorn-gunicorn-slow-to-serve-static-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!