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


-- 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
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
  1. sudo -i
  2. apt-get install apache2-threaded-dev
  3. cd ~
  4. wget http://www.fastcgi.com/dist/mod_fastcgi-SNAP-0910052141.tar.gz -- this is the tarball mentioned above
  5. extract tarball
  6. cp Makefile.AP2 Makefile
  7. make top_dir=/usr/share/apache2
  8. make top_dir=/usr/share/apache2 install
  9. apache2ctl stop
  10. apache2ctl start
No additional configuration was needed once complete. Response time went from 15s to 2ms

-- ChristopherMeister - 06 May 2011

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Accelerators or modperl or FastCGI
Topic Summary Some installations suffer a delay equal to the KeepAliveTimeout value configured in apache.conf
Interested Parties
Related Topics
Topic revision: r8 - 27 Dec 2011, ArthurClemens
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy