Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Django (fastcgi, apache mod_wsgi, uwsgi, gunicorn)

Can someone explain the difference between apache mod_wsgi in daemon mode and django fastcgi in threaded mode. They both use threads for concurrency I think. Supposing that I'm using nginx as front end to apache mod_wsgi.

UPDATE:

I'm comparing django built in fastcgi(./manage.py method=threaded maxchildren=15) and mod_wsgi in 'daemon' mode(WSGIDaemonProcess example threads=15). They both use threads and acquire GIL, am I right?

UPDATAE 2:

So if they both are similar, is there any benefits of apache mod_wsgi against fastcgi. I see such pros of fastcgi:

  • we don't need apache
  • we consume less RAM
  • I noticed that fastcgi has lesser overhead

UPDATAE 3:

I'm now happy with nginx + uwsgi.

UPDATAE 4:

I'm now happy with nginx + gunicorn :)

like image 749
Roman Dolgiy Avatar asked Apr 07 '10 10:04

Roman Dolgiy


1 Answers

Neither have to use threads to be able to handle concurrent requests. It depends on how you configure them. You can use multiple processes where each is single threaded if you want.

For more background on mod_wsgi process/threading models see:

http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

The models are similar albeit that mod_wsgi handles process management itself. What happens in FASTCGI as far as process management depends on what FASTCGI hosting mechanism you are using and you don't say what that is.

Another difference is that FASTCGI still needs a separate FASTCGI to WSGI bridge such as flup where as mod_wsgi doesn't need any sort of bridge as implements WSGI interface natively.

Finally, FASTCGI process are an exec/fork of some supervisor process or the web server, dependent on hosting mechanism. In mod_wsgi the processes are a fork only of Apache parent process. In general this doesn't matter too much but does have some implications.

There are other differences but they arise more because mod_wsgi offers a lot more functionality and configurability than a FASTCGI hosting mechanism does.

Anyway, the question is a bit vague, can you be more specific about what it is you are wanting to know or contrast between the two and why? Answer can then perhaps be targeted better.

like image 76
Graham Dumpleton Avatar answered Sep 19 '22 18:09

Graham Dumpleton