mod_python performs several magnitudes slower than PHP?

John Nagle nagle at animats.com
Sat May 19 20:01:04 EDT 2007


    That's puzzling, because with mod_python, you're only invoking
the compiler once per Apache restart.  With CGI programs, you pay
the loading penalty on every request.

				John Nagle

chris.monsanto at gmail.com wrote:
> Recently I've had to move my site to a new dedicated server running
> FreeBSD 6.1. After installing apache 2.0.59, python 2.4.4 and
> mod_python 3.3.1, I decided to bench a script in PHP vs one in Python.
> I found out that for some reason, my mod_python was performing
> extremely slow - magnitudes slower than it should. I scowered the
> internet for hours and asked a few friends and still haven't been able
> to find a solution to the problem.
> 
> from mod_python import apache
> 
> def handler(req):
>   for i in xrange(1000):
>     print >> req, "Yeah"
>   return apache.OK
> 
> and...
> 
> <?
>   for ($i = 0; $i < 1000; $i++)
>     echo "Yeah\n" ;
> ?>
> 
> when I ran ab on both using 1000 requests and a concurrency of 10, i
> got these results:
> 
> python- Requests per second:    21.37 [#/sec] (mean)
> php- Requests per second:    1008.37 [#/sec] (mean)
> 
> Any ideas would really be appreciated... I'm on my last leg.
> 



More information about the Python-list mailing list