gpt4 book ai didi

python - 在 Linux VM 上托管 Django 项目时使用 Gunicorn 有什么意义

转载 作者:太空宇宙 更新时间:2023-11-04 04:55:17 24 4
gpt4 key购买 nike

我有一个在 Google Compute Engine 上运行的 Linux 实例。我在上面安装了 pip 和 django,并克隆了我在本地处理的 Django 项目。就像我在本地主机上一样,我运行我的应用程序,如下所示:python3 manage.py runserver 0.0.0.0:8080,并且我的服务器已启动并运行,没有任何问题。我在网上读到如何让 Python 应用程序在服务器上良好运行需要 WSGI 服务器,但是我不明白为什么我需要像 Gunicorn 这样的东西来运行我的应用程序

最佳答案

这就是 the documentation for runserver说:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

Django 的 runserveritself a WSGI server ,但其目的是让开发人员易于使用。

uWSGI 和 Gunicorn 等生产 WSGI 服务器会考虑性能和生产环境。它们可以更好地处理并发,速度更快,并且旨在抵御恶意用户,而不仅仅是开发人员。

关于python - 在 Linux VM 上托管 Django 项目时使用 Gunicorn 有什么意义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48235701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com