python - 这两种运行 Django 的配置有什么区别?

标签 python django apache fastcgi django-wsgi

我有这两种配置。我想知道有什么区别,哪个更好更快?

第一个配置:

#!/home/user/bin/python
import sys, os
sys.path.insert(0,"/home/user/projects/")
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'

from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

第二种配置:

#!/home/user/bin/python
import sys, os
sys.path.insert(0,"/home/user/projects/")
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

谢谢!

更新:

I did a quick test with python cProfile lib .

最佳答案

Django native 使用 WSGI,因此通过 FastCGI 运行它为 HTTP 消息传输增加了另一层。话虽如此,如果您可以在快速的 FastCGI 容器或慢速的 WSGI 容器之间做出选择,您最好还是使用额外的层。

关于python - 这两种运行 Django 的配置有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7690839/

相关文章:

python - 从 MongoDB (PyMongo) 访问集合时出现关键错误

Django DateTimeField 不可编辑

linux - 重定向 301 www.www.example.com

python - 用 Arduino 和 pySerial 闪烁 LED

python - Mechanize/CookieJar 不保持 session 持久性

python - djangorest-framework单例ViewSet

apache - 如何修复 java IOException : Can't find resource 'solrconfig.xml' in classpath?

php 到 csv 和特殊字符

Python 类型 'Instance' 转换

python - 为什么使用 icontains 过滤 django 区分大小写?