FastCGI
Encyclopedia
FastCGI is a protocol for interfacing interactive programs with a web server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

. FastCGI is a variation on the earlier Common Gateway Interface
Common Gateway Interface
The Common Gateway Interface is a standard method for web servers software to delegate the generation of web pages to executable files...

 (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI
Common Gateway Interface
The Common Gateway Interface is a standard method for web servers software to delegate the generation of web pages to executable files...

 programs, allowing a server to handle more web page requests at once.

History

CGI is a protocol for interfacing external applications to web servers. CGI applications run in separate processes
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

, which are created at the start of each request and torn down at the end. This "one new 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
OpenMarket
Open Market was an ecommerce startup, founded in Cambridge, Massachusetts in early 1994. It went public in 1996 on the Nasdaq exchange under the symbol OMKT, as one of the first ecommerce IPOs...

 developed FastCGI and first introduced it in their webserver product in the mid-1990s. Open Market originally developed FastCGI in part as a competitive response to Netscape's
Netscape
Netscape Communications is a US computer services company, best known for Netscape Navigator, its web browser. When it was an independent company, its headquarters were in Mountain View, California...

 proprietary, in-process API (NSAPI
Netscape Server Application Programming Interface
The Netscape Server Application Programming Interface is an application programming interface for extending server software, typically web server software.-History:...

) for developing Web applications.

Although initially developed by Open Market
OpenMarket
Open Market was an ecommerce startup, founded in Cambridge, Massachusetts in early 1994. It went public in 1996 on the Nasdaq exchange under the symbol OMKT, as one of the first ecommerce IPOs...

, 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. Apache
Apache HTTP Server
The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

 modules such as mod perl
Mod perl
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request...

 and mod php appeared around the same time, and they also quickly gained popularity. Today, all of these various approaches (including CGI) remain in common use.

Implementation details

Instead of creating a new process for each request, FastCGI uses persistent processes to handle a series of requests. These processes are owned by the FastCGI server, not the web server.

To service an incoming request, the web server sends environment information
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

 and the page request itself to a FastCGI process over a socket (in the case of local FastCGI processes on the web server) or TCP connection (for remote FastCGI processes in a server farm
Server farm
A server farm or server cluster is a collection of computer servers usually maintained by an enterprise to accomplish server needs far beyond the capability of one machine. Server farms often have backup servers, which can take over the function of primary servers in the event of a primary server...

). Responses are returned from the process to the web server over the same connection, and the web server subsequently delivers that response to the end-user. The connection may be closed at the end of a response, but both the web server and the FastCGI service processes persist.

Each individual FastCGI process can handle many requests over its lifetime, thereby avoiding the overhead of per-request process creation and termination. Processing of multiple requests simultaneously can be achieved in several ways: by using a single connection with internal multiplexing (i.e. multiple requests over a single connection); by using multiple connections; or by a combination of these techniques. Multiple FastCGI servers can be configured, increasing stability and scalability.

Web site administrators and programmers can find that the separation of web applications from the web server in FastCGI has many advantages over embedded interpreters (mod perl
Mod perl
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request...

, mod php, etc.). This separation allows server and application processes to be restarted independently – an important consideration for busy web sites. It also enables the implementation of per-application / hosting service security policies, which is an important requirement for ISPs and web hosting companies. Different types of incoming requests can be distributed to specific FastCGI servers which have been equipped to handle those particular types of requests efficiently.

Web Servers that implement FastCGI

Note: unless stated, completeness of FastCGI implementation is unknown
  • Abyss Web Server
  • Apache HTTP Server
    Apache HTTP Server
    The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

     (partial)
    • Implemented by mod_fcgid. This module used to be third-party, but was granted to the ASF
      Apache Software Foundation
      The Apache Software Foundation is a non-profit corporation to support Apache software projects, including the Apache HTTP Server. The ASF was formed from the Apache Group and incorporated in Delaware, U.S., in June 1999.The Apache Software Foundation is a decentralized community of developers...

       as an Apache HTTP Server subproject in 2009, shepherded by Chris Darroch.
    • An older, third-party module mod_fastcgi is also being used.
    • Multiplexing of requests through a single connection is prohibited by Apache 1.x design, so this isn't supported
  • Cherokee HTTP Server
    Cherokee (Webserver)
    Cherokee is an open-source Cross-platform Web server that runs on Linux, BSD variants, Solaris, Mac OS X, and Microsoft Windows. It is a lightweight, high-performance Web Server/reverse proxy licensed under the GNU General Public License. Its goal is to be fast and fully functional yet still light...

  • Hiawatha webserver
    Hiawatha webserver
    Hiawatha is a secure webserver available for multiple platforms. It has been developed by Hugo Leisink since 2002.-History:Hiawatha started in January 2002 as a very small webserver, suitable for servers with old hardware. It was written for internet servers in student houses in Delft...

    • Loadbalancing FastCGI support
    • Supports chrooted FastCGI servers
  • Lighttpd
    Lighttpd
    lighttpd is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible...

  • LiteSpeed Web Server
  • Microsoft IIS
  • Kerio WebSTAR
    Kerio WebSTAR
    Kerio WebSTAR is an HTTP web server for Mac OS X with older versions running on classic Mac OS....

  • Nginx
    Nginx
    nginx is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, and Microsoft Windows.- Overview...

  • Open Market Web Server
    OpenMarket
    Open Market was an ecommerce startup, founded in Cambridge, Massachusetts in early 1994. It went public in 1996 on the Nasdaq exchange under the symbol OMKT, as one of the first ecommerce IPOs...

  • pronghorn Web Server
  • Resin Application Server
    Resin Server
    Resin is a software product, a web server and Java application server from Caucho Technology. Resin is provided in two versions, Resin Professional and Resin Open Source ....

  • Roxen Web Server
    Roxen (web server)
    Roxen is a free software web server produced by Roxen Internet Software, a company based in Linköping, Sweden and named after the nearby lake Roxen. It is released under the GNU General Public License. Roxen originally appeared as Spinner in the mid-1990s and was written in a C-like language called...

  • Sun Java System Web Server
  • Any Servlet container (such as Apache Tomcat
    Apache Tomcat
    Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation...

     or Jetty
    Jetty (web server)
    Jetty is a pure Java-based HTTP client/server, WebSocket client/server and servlet container developed as a free and open source project as part of the Eclipse Foundation...

    ), using the JFastCGI library.
  • Zeus Web Server
    Zeus Web Server
    Zeus Web Server is a proprietary web server for Unix and Unix-like platforms . Support for AIX, Tru64, and Mac OS X was dropped on 10 June 2008....

  • http://www.myserverproject.net

Language bindings for the FastCGI API

FastCGI can be implemented in any language that supports socket
Socket
Socket may refer to:In mechanics:* Socket wrench, a type of wrench that uses separate, removable sockets to fit different sizes of nuts and bolts...

s. (Since "FastCGI is a protocol, not an implementation," it is not tightly bound to any language at all.) API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

s exist for:
  • Ada
    Ada (programming language)
    Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages...

  • Borland Delphi
    Borland Delphi
    Embarcadero Delphi is an integrated development environment for console, desktop graphical, web, and mobile applications.Delphi's compilers use its own Object Pascal dialect of Pascal and generate native code for 32- and 64-bit Windows operating systems, as well as 32-bit Mac OS X and iOS...

    /Lazarus FreePascal
  • C
    C (programming language)
    C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

     / C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

  • Chicken Scheme
  • Common Lisp
    Common Lisp
    Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 , . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers...

    : CLISP
    CLISP
    In computing, CLISP is an implementation of the programming language Common Lisp originally developed by Bruno Haible and Michael Stoll for the Atari ST...

     and CMUCL
    CMUCL
    CMUCL is a free Common Lisp implementation, originally developed at Carnegie Mellon University.CMUCL runs on most Unix-like platforms, including Linux and BSD; there is an experimental Windows port as well. Steel Bank Common Lisp is derived from CMUCL...

  • D programming language
    D (programming language)
    The D programming language is an object-oriented, imperative, multi-paradigm, system programming language created by Walter Bright of Digital Mars. It originated as a re-engineering of C++, but even though it is mainly influenced by that language, it is not a variant of C++...

  • Eiffel
    Eiffel (programming language)
    Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method...

  • Go
    Go (programming language)
    Go is a compiled, garbage-collected, concurrent programming language developed by Google Inc.The initial design of Go was started in September 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. Go was officially announced in November 2009. In May 2010, Rob Pike publicly stated that Go was being...

  • Guile Scheme
  • Haskell
    Haskell (programming language)
    Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...

  • HP BASIC for OpenVMS
    HP BASIC for OpenVMS
    HP BASIC for OpenVMS is the latest name for a dialect of the BASIC programming language created by Digital Equipment Corporation and now owned by Hewlett-Packard. Although it was developed before VMS on the PDP-11 platform, it was later ported to VMS on VAX then OpenVMS on Alpha...

  • Java
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

  • Lua
  • Mono XSP
  • OCaml
  • Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

  • PHP
    PHP
    PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

  • Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

  • REALbasic (REAL Studio)
    REALbasic
    Realbasic is the object-oriented dialect of the BASIC programming language used in Real Studio, a programming environment, developed and commercially marketed by Real Software, Inc of Austin, Texas for Mac OS X, Microsoft Windows, 32-bit x86 Linux and the web.- Language features :RB is a strongly...

  • Roadsend PHP
  • Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

  • SmallEiffel
  • Smalltalk
    Smalltalk
    Smalltalk is an object-oriented, dynamically typed, reflective programming language. Smalltalk was created as the language to underpin the "new world" of computing exemplified by "human–computer symbiosis." It was designed and created in part for educational use, more so for constructionist...

    : FasTalk and Dolphin Smalltalk
    Dolphin Smalltalk
    Dolphin Smalltalk, or "Dolphin" for short , is an implementation of the Smalltalk programming language by Object Arts, targeted at the Microsoft Windows platform.The last major release was Dolphin Smalltalk X6, which comes in two versions:...

  • Tcl
    Tcl
    Tcl is a scripting language created by John Ousterhout. Originally "born out of frustration", according to the author, with programmers devising their own languages intended to be embedded into applications, Tcl gained acceptance on its own...



Recent frameworks such as Ruby on Rails
Ruby on Rails
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language.-History:...

, Catalyst
Catalyst (software)
Catalyst is an open source web application framework written in Perl, that closely follows the model–view–controller architecture, and supports a number of experimental web patterns. It is written using Moose, a modern object system for Perl...

, Django, Kepler
Kepler (software)
Kepler is a free software project written in Lua that provides a portable, extensible website development platform. Current stable release is Kepler 1.1.1, for Lua 5.1. Kepler works on Windows and most variants of Unix....

 and Plack
Plack (software)
Plack is a set of tools for running Perl-based Web applications and frameworks compatible with the PSGI specification.Plack was inspired by Rack for Ruby and Paste for Python.Plackup is a command-line tool for running the PSGI applications,...

 allow use with either the embedded interpreters (mod ruby
Mod ruby
mod_ruby is a module that embeds the Ruby interpreter into the Apache web server to allow Ruby code to execute natively, faster than other CGI methods. Its drawback is that the characteristic sharing of classes among Apache processes is not safe for multiple applications mod_ruby is a module that...

, mod perl
Mod perl
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request...

, mod python
Mod python
mod_python is an Apache HTTP Server module that integrates the Python programming language into the Apache server. It is intended to replace Common Gateway Interface as a method of executing Python scripts on a web server. The promised benefits are faster execution speed and maintaining data over...

 or mod lua
Kepler (software)
Kepler is a free software project written in Lua that provides a portable, extensible website development platform. Current stable release is Kepler 1.1.1, for Lua 5.1. Kepler works on Windows and most variants of Unix....

, for example), or FastCGI.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK