[mod_python] ApplicationPath kills performance?

Jason Stubbs jstubbs at work-at.co.jp
Mon Sep 12 07:25:29 EDT 2005

Hi all,

Just started using mod_python. I searched the archives on this, but 
could only find issues about sessions not working. I can get sessions 
working if I set ApplicationPath but things become about 1/100th of the 
original speed.

The config (outside of any Directory section - adding it to a Directory 
section has the same affect):

DirectoryIndex index.psp
AddHandler mod_python .psp
PythonHandler mod_python.psp
PythonPath "['/var/www/localhost/pythonlib']+sys.path"
PythonOption ApplicationPath /

And then from a different machine:

$ ./ab -c 5 -n 500
Requests per second:    3.85 [#/sec] (mean)

However, after removing the ApplicationPath:

Requests per second:    552.10 [#/sec] (mean)

What might be the cause of this huge difference? I noted in some 
previous posts that some are setting ApplicationPath relative to their 
DocumentRoot while others are setting it relative to /. Which is 
correct? (Neither makes a difference to speed, though)

Adding 'PythonOption SessionDbm /tmp/sessions.dbm' yields a small increase:

Requests per second:    11.38 [#/sec] (mean)

However, I don't understand why this could be seeing that my index.psp 
doesn't actually set up any sessions unless parameters are specified. 
The code can currently be summarised as:

username = None
if "username" in psp.form:
	# do authentication
	# possibly set up a session and redirect

Some stuff
if username:
Invaild username!
Some other stuff

Obligatory version information is as follows:

httpd       2.0.54-r9
mod_python  3.1.3-r1
python      2.4.1-r1
(-r components are Gentoo patch-levels)

Any help would be appreciated.

Jason Stubbs

More information about the Mod_python mailing list