Why does FastCGI cause the browser to pause 15+ seconds on each view?
This advice applies to mod_fastcgi
, not the newer mod_fcgid
which ships with apache. Please use mod_fcgid
instead of mod_fastcgi
, which does not appear to be actively maintained
The
pylons documentation describes it best:
Correcting the KeepAlive Problem
Once you have a working version of your application using FastCGI there is a chance you may experience a strange problem where the script runs but the browser doesn't stop waiting for it for say 30-45 seconds. This is a known issue with mod_fastcgi and graceful restarts but doesn't seem to be getting fixed very fast.
What is happening is that the script is being kept alive by the KeepAlive HTTP header which in turn is being set because of the KeepAlive
directive in httpd.conf
.
PaulHarvey has experienced this problem on Ubuntu 9.04. The latest packaged version of
FastCGI is 2.4.6.
The solution was to compile and install the semi-official "SNAP" 2.4.7 and install it locally. The tarball used was
this one.
--
PaulHarvey - 21 Feb 2010
Very strange. I am using ubuntu's libapache2-mod-fastcgi 2.4.6-1 and never ever experienced any such problem.
--
MichaelDaum - 08 Apr 2010
After further discussion, it seems Michael has success using dynamic
FastCGI servers:
FastCgiConfig -idle-timeout 180 -minProcesses 1 -maxClassProcesses 20 -maxProcesses 50 -startDelay 5
http://irclogs.foswiki.org/bin/irclogger_log/foswiki?date=2010-04-08,Thu&sel=361#l357
--
PaulHarvey - 08 Apr 2010
Testing this advice, sadly, it still doesn't work for me - at least not on Debian squeeze. Roughly, to compile fastcgi sources linked above:
apt-get install apache2-prefork-dev
sudo ln -s /usr/share/apache2 /usr/local/apache2
cp Makefile.AP2 Makefile
make
sudo make install
sudo /etc/init.d/apache2 restart
--
PaulHarvey - 11 Jun 2010
To fix the fastcgi response time on Ubuntu 10.10 and apache2
- sudo -i
- apt-get install apache2-threaded-dev
- cd ~
- wget http://www.fastcgi.com/dist/mod_fastcgi-SNAP-0910052141.tar.gz -- this is the tarball mentioned above
- extract tarball
- cp Makefile.AP2 Makefile
- make top_dir=/usr/share/apache2
- make top_dir=/usr/share/apache2 install
- apache2ctl stop
- apache2ctl start
No additional configuration was needed once complete. Response time went from 15s to 2ms
--
ChristopherMeister - 06 May 2011