NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: FastCGI



Hi--

On Jan 6, 2010, at 2:12 PM, Sad Clouds wrote:
> I'm reading FastCGI specification and have a few questions in regard how a 
> web 
> server and FastCGI applications inter operate.
> 
> 1. When a web server reads HTTP request for something like *.php file, does 
> it 
> pass all HTTP headers + client data to php-cgi, or does it remove some of the 
> headers?

The HTTP headers get passed to the CGI program as environment variables (eg, 
HTTP_USER_AGENT, etc); Apache comes with a simple example called "printenv" 
which will display all of the variables and their values.  See the fine docs:

  http://httpd.apache.org/docs/2.2/howto/cgi.html
  http://hoohoo.ncsa.illinois.edu/cgi/env.html

...and whatever PHP provides for CGI support.

> 2. When php-cgi writes a response, it passes it back to the web server. Does 
> web server prepend its own HTTP headers and send it to the client? Is there 
> some sort of agreement between web servers and FastCGI applications who is 
> responsible for what headers?

A CGI program is expected to provide at least the Content-type: header, but it 
can also provide more headers if it wants.  The webserver itself might update 
the list of headers with Content-length:, HTTP/1.1 Connection: headers, etc.

> 3. Assume web server runs on one machine and distributes the load to many php-
> cgi instances on different machines. Is there some sort of mechanism for web 
> server to control the number of requests sent to each instance (depending on 
> currents load, free memory, etc) and explicit shutdown of runaway CGI 
> applications?

That's up to FastCGI to deal with.  In other environments, I've used hardware 
load-balancers from ServerIron or NetApp to handle "is the instance alive" 
testing and failover, or software like WebObjects which is aware of instance 
availability & load and has mechanisms for choosing whether to round-robin, 
distribute to the least loaded instance, etc.

Regards,
-- 
-Chuck



Home | Main Index | Thread Index | Old Index