FCGI app reloading on every request

John Nagle nagle at animats.com
Tue Sep 4 00:26:01 EDT 2007


    I'm converting a web app from CGI to FCGI.  The application works fine
under FCGI, but it's being reloaded for every request, which makes FCGI
kind of pointless.  I wrote a little FCGI app which prints when the program is 
loaded and when it gets a request.  And indeed, the program gets reloaded for
each HTTP request.  Something is probably misconfigured.  But what?

    I'm using Apache with "mod_fcgid", configured via Plesk.  Plesk
sets up "/etc/httpd/conf.d/fcgid.conf" with:

# added by psa-mod-fcgid-configurator
<IfModule mod_fcgid.c>
   IdleTimeout 3600
   ProcessLifeTime 7200
   MaxProcessCount 64
   DefaultMaxClassProcessCount 8
   IPCConnectTimeout 30
   IPCCommTimeout 45
   DefaultInitEnv RAILS_ENV production
</IfModule>

which seems reasonable enough, even though I'm not using
Rails or Ruby.

On the Python side, I'm using Python 2.5 on Linux, with Alan
Saddi's "fcgi.py" module.

Everything seems to work correctly, and there are no errors in the Apache
error log.  But performance is terrible because the Python code
is reloaded for each request.  I can only get about five transactions
a second through, on an dedicated server, with each transaction
doing a simple MySQL request.  All the time is going into program loading;
the database is mostly idle.

				John Nagle



More information about the Python-list mailing list