FastCGI

From Wikipedia, the free encyclopedia

FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a website to scale up to handle more concurrent requests.

Contents

[edit] History

CGI is a protocol for interfacing external applications to web servers. CGI applications run in a separate process, which is created at the start of each request and torn down at the end. This "one process per request" model makes CGI programs very simple to implement, but limits efficiency and scalability. At high loads, the operating system process creation and destruction overhead becomes significant and limits scalability. In addition, the CGI process model limits resource reuse techniques (such as reusing database connections, in-memory caching, etc.).

To address the scalability shortcomings of CGI, Open Market developed FastCGI and first introduced it their webserver product in the mid-1990s. Open Market originally developed FastCGI in part as a competitive response to Netscape's proprietary, in-process API (NSAPI) for developing Web applications.

[edit] Implementation details

Instead of creating a new process for every request, FastCGI uses a single persistent process which handles many requests over its lifetime. Processing of multiple requests simultaneously is achieved either by using a responder process with internal multiplexing, or by using more responder processes. FastCGI also allows programs to get the web server to do certain simple operations, like reading in a file, before the request is handed over. Environment information and page requests are sent from the web server to the process over a TCP connection (for remote processes) or Unix domain sockets (for local processes). Responses are returned from the process to the web server over the same connection. The connection may be closed at the end of a response, but the web server and the process are left standing.

Although initially developed by Open Market, FastCGI was implemented by a number of other webserver makers. The FastCGI approach, however, competed against other techniques which also aimed to speed and simplify server-subprogram communications, but which didn't follow the CGI paradigm. Apache modules such as mod_perl and mod_php appeared around the same time and seemed to be even better replacements for CGI, allowing closer integration with the core webserver.

FastCGI languished for many years; however, later years have seen a resurgence in interest in FastCGI [citation needed]. Many web site administrators and programmers are finding that the separation of web applications from the web server in FastCGI (and the simpler SCGI) has many desirable advantages over embedded interpreters (mod_perl, mod_php, etc.). This separation allows server and application processes to be restarted independently — an important consideration for busy web sites. It also facilitates per-application security policies — important for ISPs and web hosting companies.

[edit] Web Servers that implement FastCGI

[edit] Language bindings for the FastCGI API

FastCGI can be implemented in any language that supports sockets. API's exist for:

FastCGI has enabled web application portability; in contrast, applications developed for embedded interpreters (such as mod_python) are often tightly bound to the Apache API. Recent frameworks such as Ruby on Rails, Catalyst, and Django allow use with either the embedded interpreters (mod_ruby, mod_perl, or mod_python respectively) or with FastCGI.

[edit] References

  1. ^ FastCGI for Cherokee
  2. ^ FastCGI for Lighttpd

[edit] External links

In other languages