[Answered ]-Does a production DJango server fork?

2👍

I’m sure that it depends on your deployment, but if you are running it under FastCGI or WSGI, then yes, it generally pre-forks a number of server processes to handle incoming requests.

I don’t know about running under mod_python, but I think that is being discouraged these days in favour of WSGI.

0👍

I’m not an expert in this field so I’m answering based only on the grep-ing I’ve just done.

The fastcgi server seems to be able to fork, depending on configuration settings:

http://code.djangoproject.com/browser/django/tags/releases/1.2.3/django/core/servers/fastcgi.py#L171
http://code.djangoproject.com/browser/django/tags/releases/1.2.3/django/utils/daemonize.py

As for WSGI, I believe that Django side-handling is going straight to the request processing:

http://code.djangoproject.com/browser/django/tags/releases/1.2.3/django/core/handlers/wsgi.py#L217

and forking is configured in mod_wsgi: http://code.google.com/p/modwsgi/ – embedded mode vs daemon mode – and/or in Apache (worker vs prefork builds).

0👍

For mod_wsgi, read:

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

It explains the various models and guidelines in respect to use of common data across threads/processes. Situation isn’t much different for other hosting systems.

Leave a comment