pythondjangoapachefastcgidjango-wsgi

What is the difference between these two configurations to run Django?


I have these two configurations. I would like to know what's the difference and which one is better and faster?

First configuration:

#!/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()

Second configuration:

#!/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")

Thanks!

Update:

I did a quick test with python cProfile lib.


Solution

  • Django uses WSGI natively, so running it through FastCGI adds another layer for the HTTP messages to travel through. Having said that, if you have the choice between a quick FastCGI container or a slow WSGI container, you may be better off living with the extra layer.