mod_python - Using Apache prefork Vs Apache worker

411 views
Skip to first unread message

Filipe

unread,
Sep 5, 2006, 2:45:01 PM9/5/06
to Django users
Hi,

The docs say [1] that:
"Django requires Apache 2.x and mod_python 3.x, and you should use
Apache's prefork MPM, as opposed to the worker MPM."

I want to test a Django site on a server (I plan to deploy there some
other sites in the future) where there are installed Apache 2 and
mod_python 3.1.4.

I've seen some references [2][3] that make me suspect that the issues
that existed with mod_python and Apache worker might have been solved
in mod_python 3.2.8.

What problems can I expect if I use mod_python 3.1.4?
Do you think the problems might have been fixed in 3.2.8?

[1] http://www.djangoproject.com/documentation/modpython/
[2] http://www.djangoproject.com/documentation/modpython/#c2029
[3]
http://groups.google.com/group/django-users/browse_frm/thread/843ab71c4ffaf4a0/688749b6e7dd1c45

gabor

unread,
Sep 5, 2006, 3:21:18 PM9/5/06
to django...@googlegroups.com
Filipe wrote:
> Hi,
>
> The docs say [1] that:
> "Django requires Apache 2.x and mod_python 3.x, and you should use
> Apache's prefork MPM, as opposed to the worker MPM."
>
> I want to test a Django site on a server (I plan to deploy there some
> other sites in the future) where there are installed Apache 2 and
> mod_python 3.1.4.
>
> I've seen some references [2][3] that make me suspect that the issues
> that existed with mod_python and Apache worker might have been solved
> in mod_python 3.2.8.
>
> What problems can I expect if I use mod_python 3.1.4?
> Do you think the problems might have been fixed in 3.2.8?
>

well, generally, the "problem" with the worker MPM is that it's a
multithreaded application.

which means, that if you want to have your app in a worker MPM, it has
to be thread-safe. and i don't know if django is thread-safe or not (i
think it's not).

also, when doing multithreaded python applications, the GIL (python's
global interpreter lock) might become an issue.

so, i'd recommend, that if you have enough memory, use the prefork MPM.

gabor

Graham Dumpleton

unread,
Sep 7, 2006, 6:10:33 AM9/7/06
to Django users

If the inability to use worker MPM is because Django doesn't support
multithreading, then it would be impossible to use Django on Windows
as Apache there can only run with a multithreaded MPM, there is no
multi process option.

Although I have asked previously why it is said that the worker MPM
shouldn't be used, no one has yet given a definitive answer.

Also, saying the GIL might become an issue, this is no more than for
any other multithreaded application. One shouldn't be bringing the GIL
into this, as it has got nothing to do in practice with whether the
worker MPM can be used.

Graham

gabor

unread,
Sep 6, 2006, 2:00:52 PM9/6/06
to django...@googlegroups.com


hmmm.. then it seems i misunderstood your question, sorry.

if your question is more of an academic nature of "is it possible?",
then for that i do not know the answer. it definitively is not the best
way to run it, but maybe it is possible.

gabor

Niels

unread,
Sep 8, 2006, 8:33:22 AM9/8/06
to Django users
Hi there

Just to report on this, i set up a machine with very little memory
using apache 2.2.1 (worker mpm), with mod_python 3.3 (development
version 20060520) and django. It seems there is nothing much in django
nor python that isn't thread safe. External C libraries you load as a
python module might bring up issues.

This installation is for development and never stands a high load.
Worker mpm is setup to handle 20 threads in a single process, which
causes all requests to be handled through the same resident python
interpreter under normal load.

Main problem here is that there isn't enough memory to keep both apache
worker process and mysql instance resident. This results in swapping
and delays, but no timeouts, crashes or coredumps seen.

Reply all
Reply to author
Forward
0 new messages