python - 为什么 Unicorn/Gunicorn 提供静态内容的速度很慢?

标签 python django nginx gunicorn unicorn

我已阅读here Unicorn/Gunicorn HTTP 服务器“不太擅长提供静态文件”,而 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.

Source

考虑这样一种情况:有 100 位访问者使用 56k 调制解调器尝试观看 400mb 的视频。您确实不想在内存中保存应用程序的 100 个实例,或者将文件加载到内存中,等等。Nginx 在设计时就考虑到了这种情况。

关于python - 为什么 Unicorn/Gunicorn 提供静态内容的速度很慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42696229/

相关文章:

nginx - Gatsby 与 nginx - 重定向已损坏 - 尾随/(斜杠)

ruby-on-rails - Nginx:无法将 HTTP 响应转发回 HTTP 客户端

python - tkinter .focus_set() 失败

python - 如何查找用户在 Django 应用程序中的登录总数?

python - django-elasticsearch-dsl : how to search across multiple documents?

Django:表单中的 request.user

python - 在python中创建一个带有初始值的md5对象

python - ValueError : Tensor conversion requested dtype int32 for Tensor with dtype float32 while using tf. 图像.crop_to_bounding_box

python - 如何删除轴、图例和白色填充

ubuntu - 在 ubuntu 上安装特定的 nginx-extras 包