为什么 Unicorn/Gunicorn 提供静态内容很慢?
Why is Unicorn/Gunicorn slow to serve static content?
我读过 here Unicorn/Gunicorn HTTP 服务器是 'not very good at serving static files',并且 Nginx 更擅长提供静态内容。有人可以解释这是为什么吗?
我了解 Nginx 和 Gunicorn 的特殊作用,Nginx 是一个反向代理,如果需要,Gunicorn 实际上可以提供静态文件。
主要是因为 Unicorn 的设计目的不是为了解决向客户提供文件所涉及的一系列问题:
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.
考虑这样一种情况,您有 100 名访问者使用 56k 调制解调器试图观看 400mb 的视频。你真的不想在内存中保存 100 个应用程序实例,或者将文件加载到内存中,等等。Nginx 在设计时就考虑到了这种情况。
我读过 here Unicorn/Gunicorn HTTP 服务器是 'not very good at serving static files',并且 Nginx 更擅长提供静态内容。有人可以解释这是为什么吗?
我了解 Nginx 和 Gunicorn 的特殊作用,Nginx 是一个反向代理,如果需要,Gunicorn 实际上可以提供静态文件。
主要是因为 Unicorn 的设计目的不是为了解决向客户提供文件所涉及的一系列问题:
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.
考虑这样一种情况,您有 100 名访问者使用 56k 调制解调器试图观看 400mb 的视频。你真的不想在内存中保存 100 个应用程序实例,或者将文件加载到内存中,等等。Nginx 在设计时就考虑到了这种情况。