[Python-Dev] importlib

John Nagle nagle at animats.com
Thu Jul 15 22:06:28 CEST 2010


anatoly techtonik<techtonik at gmail.com> wrote:
> What about web-applications? Is that true that for FastCgi or mod_wsgi
> deamon mode interpreter and application is started only once per say
> 100 requests?

    Yes.  Only CGI programs reload on every use.  FCGI/WSGI programs
run more or less forever, and are only loaded once, reading
requests and handling them.  Some FCGI systems reload their applications 
once in a while, and ask the idle ones to exit
after periods of no traffic, but that's a form of automatic
performance tuning. And, of course, there are the permanently
resident systems like Twisted.

    (Incidentally, if you run FCGI/WSGI programs under Apache,
make sure that you don't put .fcgi scripts in a directory
from which Apache will execute .cgi scripts. Apache will run
the .fcgi script with CGI, and the WSGI Python module will
detect this and run the script one time and exit for each
request.  Everything appears to work and performance is terrible.)

    If import performance is important in a production server
environment, it's more useful to look at minimizing the number
of loads rather than trying to make them faster.  If and when
Unladen Swallow finally gets going, startup times will get worse
as the JIT compiler cranks, but run time will (hopefully) decrease.

				John Nagle



More information about the Python-Dev mailing list