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

标签 python django linux google-compute-engine gunicorn

我有一个在 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/

相关文章:

python - theano 出现奇怪的语法错误

python - "Unsupported target for indexed assignment"与 mypy,取决于与分配有关的类型提示时刻

python - 如何使用 strip() 从句子中删除\n 字符

css - 使用静态文件应用程序在 Django 中应用 css 时出现问题

linux - 在centos中安装sqlite3 dev和其他包

python - pandas - 如果排名前 2,则 1

python - Non-orm Tastypie 资源流中的请求为 None

django - 如何将 View 限制为仅限 super 用户?

linux - 从批处理 Linux 到 Windows 的 awk 和 sed 命令。如何转换?

linux - 查找命令以列出在 bash 脚本中不起作用的符号链接(symbolic link)文件