The Processing of a Script in Web Server
- 0 Comments
One way to avoid the latency of CGI scripts is to keep them loaded and running all the time as a co-process. When the server needs the script to generate a page, it sends it a message and waits for the response.
The first system to use co-processing was the FastCGI protocol, released by Open Market in 1996. Under this system, the web server runs FastCGI scripts as separate processes just like ordinary CGI scripts. However, once launched, these scripts don’t immediately exit when they finish processing the initial request. Instead, they go into an infinite loop that awaits new incoming requests, processes them, and goes back to waiting. Things are arranged so that the FastCGI process’s input and output streams are redirected to the web server and a CGI-like environment is set up at the beginning of each request.
Existing CGI scripts can be adapted to use FastCGI by making a few, usually painless, changes to the script source code. Implementations of FastCGI are available for Apache, as well as Zeus, Netscape, Microsoft IIS, and other servers. However, FastCGI has so far failed to win wide acceptance in the web development community, perhaps because of Open Market’s retreat from the web server market. Fortunately, a group of volunteers have picked up the Apache mod_fastcgi module and are continuing to support and advance this freeware implementation. You can find out more about mod_fastcgi at the fast cgi website. Commercial implementations of FastCGI are also available from Fast Engines, Inc. (now dead, sorry), which provides the Netscape and Microsoft IIS versions of FastCGI.
Another co-processing system is an Apache module called mod_jserv , which you can find at the project homepage, mod_jserv allows Apache to run Java servlets using Sun’s servlet API. However, unlike most other servlet systems, mod_jserv uses something called the “JServ Protocol” to allow the web server to communicate with Java scripts running as separate processes.