Isolated: Was: [mod_python] ModPython + Virtual Hosting Apache2 instance = poor performance.

Graham Dumpleton graham.dumpleton at
Sun Mar 7 21:59:16 EST 2010

On 8 March 2010 13:42, Christopher Sean Hilton <chris at> wrote:
> On Mar 7, 2010, at 6:06 PM, Graham Dumpleton wrote:
>> You said you were using PHP, so you cant use worker MPM with Apache.
>> You can still use mod_wsgi with prefork MPM, just ensure you run WSGI
>> application in daemon mode of mod_wsgi to avoid issues discussed in
>> article. Do note though that you can't use mod_wsgi with a Python
>> installation which hasn't been compiled with thread support. You also
>> cannot use daemon mode with a APR library for Apache that doesn't have
>> thread support.
> Thanks for the tip, That would have been a real huge problem.
>> Rebuilding Python without threading should not cause such a dramatic
>> improvement especially considering I recollect you had only loaded
>> mod_python and not used it. I would suggest your rebuilding has seen
>> some other change. I also don't know what earlier post you are talking
>> about as there was no such post in this current thread on mod_python
>> list.
> I didn't make any quantitative measurements. Here's what I observed:
> Browsing this page with the "broken" configuration took approximately 1min to load all of the thumbnails. In the "fixed" configuration it loads instantly. N.B. that I'm looking at this over 100Mbit LAN.
> The thread Martin pointed to seemed to conjecture that the problem has to do with apache under FreeBSD being single threaded and thus depending on while a threaded python and thus a mod_python built to use it depends on I believe the thread mentions a patch by you but it may be a different Graham.
> I confess that I didn't understand the whole thing. What I took from it is that I'm going to have problems using a non-threaded apache with a threaded mod_python. I tested this conjecture by building a fresh FreeBSD install with fresh installs of apache 2.0.63, python2.6 and mod_python. And I can make the problem appear and disappear by simply changing the configuration of the python 2.6 build from threaded to non-threaded. I feel that I may have the logic about the reason wrong. I think its a weird vs issue. But I'm confident that I've trapped the problem.

Don't know then. Not what I would have expected unless there is a
conflict in PHP or elsewhere in Apache with forcing use of rentrant C

> To tell the truth it doesn't matter. My end goal is to run Django and nowadays Django want's mod_wsgi so I'm moving over there. What I'm learning talking to you is that as far as performance goes python want's a worker MPM apache which php cannot do.

No, neither mod_wsgi or Python require Apache worker MPM. You can
still use mod_wsgi with Apache prefork MPM, thus allowing you to still
use PHP, but you would want to ensure you configure mod_wsgi such that
it creates a separate daemon process group to run your Django instance
in, similar to how FASTCGI works. This separate daemon process group
can be multithreaded, regarded of fact that single threaded Apache
prefork MPM is used, and so can have a single Python process, keeping
memory footprint down. It is because the mod_wsgi daemon process
supports threading that Python and APR have to also support threading,
even if you aren't using threading in main Apache server processes
managed under prefork MPM.

Perhaps have a read of:


More information about the Mod_python mailing list