Re: Too many FastCGI servers with cgi-fcgi

Bill Snapper (snapper@OpenMarket.com)
Tue, 29 Apr 1997 21:06:41 -0400

Message-Id: <33669B21.1C59@openmarket.com>
Date: Tue, 29 Apr 1997 21:06:41 -0400
From: Bill Snapper <snapper@OpenMarket.com>
To: Ben Engber <ben@benhur.condenast.com>
Subject: Re: Too many FastCGI servers with cgi-fcgi

Hello,

The fact that there are 50 servers is puzzling but from your description
I can see how this could possibly happen.  Let me try and explain what I 
believe is happening and why.

The fact that you have cgi-fcgi configured to spawn 1 process means that
you could have 6 requests pending at best before another process will
attempt to be started.  This is the best case.  The reason is that
the cgi-fcgi program operates with a listen queue depth of 5 by default
(see the call to "listen" in cgi-fcgi.c).  What this means is that you
will be able to get 1 process connected to the FastCGI application and
5 more may queue up waiting to connect.  The 6th in the queue will cause
the connect to fail and this could cause the cgi-fcgi application to
spawn another process.  I would expect it to fail though as the socket
is already bound to that address most likely.

I recommend trying the following.

1) Change the default listen-queue depth from 5 to something larger.
   Ideally this should be as large as the anticipated load.  For 
   example, if you have 5 servers (FastCGI applications) running and
   you anticipate a potential concurrent load of 20 requests, try 
   setting the listen queue depth to 15 or more.  Note that not all
   operating systems actually obey the setting passed to the "listen"
   system call though most commercial OS' do.

2) Change your FastCGI script to allow more processes so that you can
   actually get concurrent processing of requests destined for this
   script.

The ideal solution would be to convert the cgi-fcgi program to a native
server plugin and to make the FastCGI library multi-threaded so that you
could run multi-threaded FastCGI applications.

Hope this info is helpful.

- Bill -

-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bill Snapper           | Open Market, Inc.   | My opinions are my own,
Software Engineer      | 245 First St.       | and not necessarily
snapper@openmarket.com | Cambridge, MA 02142 | those of my employer, 
1-617-949-7365         |                     | Open Market Inc.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++