Re: forking
Stanley Gambarin (gambarin@openmarket.com)
Fri, 25 Oct 1996 16:38:01 -0400
Message-Id: <199610252038.QAA23868@u4-138.openmarket.com>
To: Andrew Savige <andrew.savige@sb.com.au>
Subject: Re: forking
In-Reply-To: Your message of "Wed, 23 Oct 1996 13:47:37 +1000."
<2.2.32.19961023034737.0067dad0@sb.com.au>
Date: Fri, 25 Oct 1996 16:38:01 -0400
From: Stanley Gambarin <gambarin@openmarket.com>
> [Stuff removed]
> What I am trying to do is to have responder immediately
> fork a new process to handle the (possibly lengthy) request,
> then wait for the next request and so on. Is fast-cgi
> designed to work this way? If not, what is the recommended
> way of writing a remote responder?
>
> To give you a more precise idea of what I am doing, here
> is a rough map of the responder code;
>
> while (FCGI_Accept() >= 0) {
> if ((pid = fork()) < 0) {
> error
> } else if (pid == 0) {
> /* child */
> printf("Content-type: text/plain\r\n\r\n");
> printf("this is a test\n");
> sleep(2); /* simulate a lengthy request */
> FCGI_Finish();
> exit(0);
> }
> /* parent continues */
> }
>
> The child's response works, but the parent then exits
> the FCGI_Accept() loop (maybe FCGI_Accept() also calls
> FCGX_Finish() and that causes a problem?).
>
> Please help.
>
> -- Andrew
> Andrew Savige andrews@sb.com.au
>
The current design of FastCGI does not permit dynamic number of
processors (via fork or otherwise). Thus you must configure the number
of processors statically, using -processes parameter for AppClass directive.
Since all of the processes listen to the same socket, if one of them is busy,
performing lengthy computation or I/O, the others can take over with identical
functionality.
The alternative is to provide dynamic process allocation with either
threads or on-demand FastCGI apps. Both alternatives are currently not
implemented, but there are some design notes in the mod_fastcgi.c
--
*******************************************************************************
* Stanley Gambarin Open Market Inc. *
* FastCGI (soon-to-be) Guru 245 First St. Cambridge MA 02142 *
* (617) - 374 - 6565 *
* mailto://gambarin@openmarket.com *
* http://acs2.bu.edu:8001/~stanleyg (school) *
* mailto://stanleyg@cs.bu.edu *
*******************************************************************************