FastCGI
![]() | This article includes a list of generalreferences,butit lacks sufficient correspondinginline citations.(June 2010) |
FastCGIis abinary protocolfor interfacing interactive programs with aweb server.It is a variation on the earlierCommon Gateway Interface(CGI). FastCGI's main aim is to reduce the overhead related to interfacing between web server and CGI programs, allowing a server to handle more web page requests per unit of time.
History
[edit]Common Gateway Interface(CGI) is a protocol for interfacing external applications to web servers. CGI applications run in separateprocesses,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, theoperating systemoverhead for process creation and destruction becomes significant. Also, the CGI process model limits resource reuse methods, such as reusing database connections, in-memory caching, etc.
To address the scalability shortcomings of CGI,Open Marketdeveloped FastCGI and first introduced it in their webserver product in the mid-1990s. Open Market originally developed FastCGI in part as a competitive response toNetscape's proprietary, in-processapplication programming interfaces(APIs) (Netscape Server Application Programming Interface(NSAPI)) for developing Web applications.
While developed first by Open Market, FastCGI was then implemented by several other webserver makers. However, its approach competed against other methods to speed and simplify server-subprogram communication.Apache HTTP Servermodules such asmod_perlandmod_phpappeared around the same time, and gained popularity quickly. As of 2020[update],all of these various methods, including CGI, remain in common use.
Implementation details
[edit]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.[1]
To service an incoming request, the web server sendsenvironment variableinformation and the page request to a FastCGI process over either aUnix domain socket,anamed pipe,or aTransmission Control Protocol(TCP) connection. Responses are returned from the process to the web server over the same connection, and the web server then delivers that response to theend user.The connection may be closed at the end of a response, but both web server and FastCGI service processes persist.[2]
Each individual FastCGI process can handle many requests over its lifetime, thereby avoiding the overhead of per-request process creation and termination. Processing multiple requests concurrently can be done in several ways: by using one connection with internalmultiple xing(i.e., multiple requests over one connection); by using multiple connections; or by a mix of these methods. Multiple FastCGI servers can be configured, increasing stability and scalability.
Web site administrators and programmers can find that separating web applications from the web server in FastCGI has many 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 enables the implementation of per-application, hosting service security policies, which is an important requirement for ISPs and web hosting companies.[3]Different types of incoming requests can be distributed to specific FastCGI servers which have been equipped to handle those types of requests efficiently.
Web servers that implement FastCGI
[edit]- Note: unless stated, completeness of FastCGI implementation is unknown
- Apache HTTP Server(partial)
- Implemented bymod_fcgid.This module used to be third-party, but was granted toThe Apache Software Foundation(ASF) as an Apache Server subproject in 2009, shepherded by Chris Darroch.[4]It only supports Unix domain sockets, no TCP sockets.[5]
- A third-party modulemod_fastcgiis also being used. For a while, this module no longer compiled properly under Apache 2.4.x,[6]although that problem has been solved with a fork of the original project.[7]
- Multiple xing of requests through one connection is prohibited by Apache 1.x design,[8]so this isn't supported
- In Apache 2.4,mod_proxy_fcgiwas added, supporting TCP FastCGI servers.
- Caddy[9]
- Cherokee[10]
- Hiawatha[11]
- Loadbalancing FastCGI support
- Supports chrooted FastCGI servers
- Jetty[12]
- Kerio WebSTAR
- Lighttpd[13]
- LiteSpeed Web Server
- Microsoft IIS[14]
- Nginx[15]
- NaviServer
- Oracle iPlanet Web Server
- OpenBSD'shttpd(8)[16]
- Open Marketweb server
- Resinweb and application server
- Roxenweb server
- ShimmerCatweb server[17]
- Zeus Web Server
Language bindings for its API
[edit]FastCGI can be implemented in any language that supportsnetwork sockets.Since "FastCGI is a protocol, not an implementation," it is not tightly bound to any one language.Application programming interfaces(APIs) exist for:[18]
- Ada[19]
- Delphi,LazarusFree Pascal[20]
- C,C++
- ChickenScheme
- Common Lisp[21]
- D
- Eiffel[22]
- Erlang
- GnuCOBOL
- Go
- GuileScheme
- Haskell
- VSI BASIC for OpenVMS
- Java[23][12]
- Lua
- node.js[24]
- OCaml
- Perl[25]
- PHP(via php-fpm,[26]orHipHop for PHP[27])
- Python
- Ruby
- Rust[28]
- SmallEiffel
- Smalltalk:FasTalk andDolphin Smalltalk
- Tcl
- WebDNA
- Vala(via C bindings)
- Xojo(formerly Realbasic, REAL Studio)[29]
Recent frameworks such asRuby on Rails,Catalyst,Django,Kepler andPlackallow use with either the embedded interpreters (mod_ruby,mod_perl,mod_ Pythonor mod_lua, for example), or FastCGI.
References
[edit]- ^"FastCGI Specification".Open Market, Inc.1996. Archived fromthe originalon 19 January 2016.
- ^"FastCGI:A High-Performance Web Server Interface".Open Market, Inc.1996. Archived fromthe originalon 1 October 2010.
- ^Heinlein, Paul (1 November 1998)."FastCGI: Persistent Applications for Your Web Server".Linux Journal.Retrieved4 October2010.
- ^FastCGI apache module mod_fcgid
- ^Debian bug #450748: Please add support for TCP/IP FastCGI servers
- ^Issues with Apache 2.4 and PHP-FPM
- ^libapache-mod-fastcgi on Github
- ^"FastCGI – The Forgotten Treasure/ Section 2.3".Archived fromthe originalon 2010-02-08.Retrieved2006-02-21.
- ^The fastcgi transport — reverse_proxy (Caddyfile directive) — Caddy Documentation
- ^FastCGI for Cherokee
- ^FastCGI howto for Hiawatha
- ^ab"FastCGI Support in Jetty".Archived fromthe originalon 2020-03-24.Retrieved2017-03-23.
- ^FastCGI for Lighttpd
- ^"FastCGI Extension for IIS6.0 – RTM".FastCGI for IIS.Microsoft. 2008-02-28.Retrieved2008-02-29.
- ^"FastCGI Nginx module ngx_http_fastcgi_module".nginx.org.NGINX, Inc.Retrieved20 June2021.
- ^OpenBSD's httpd(8) initial commit
- ^"Technical sheet".Archived fromthe originalon 2018-01-21.Retrieved2016-09-19.
- ^Application Libraries, Development Kits
- ^"Matreshka".Archived fromthe originalon 2018-01-20.Retrieved2011-10-06.
- ^ExtPascal
- ^How to use FastCGI from Common Lisp
- ^Goanna Eiffel
- ^jFastCGI, a Java Servlet implementing FastCGI protocol
- ^node-fastcgi npm package
- ^ There are several FastCGI modules for Perl: FCGI(a compiled module written in C), FCGI::Async(for asynchronous FastCGI applications), AnyEvent::FCGI (forAnyEvent-based applications), FCGI::EV (forEV-based applications), CGI::Fast (PerlCGI-like interface for FastCGI), FCGI::Client(a FastCGI client library), andNet::FastCGI (constants and functions to build and parse FastCGI messages).
- ^"PHP: FastCGI Process Manager (FPM) - Manual".
- ^FasterCGI with HHVM
- ^Several Rust crates exist: A listener implementation isfastcgi,andfastcgi-clientis a client implementation.
- ^REAL Studio Web Edition, builds web apps called via FastCGIArchived2011-02-08 at theWayback Machine
External links
[edit]- "FastCGI Archives".Retrieved2022-05-01.— fork/mirror of down FastCGI website
- Mark R. Brown (29 April 1996)."FastCGI Specification".Document version 1.0. Open Market, Inc.Retrieved2022-05-01.
- "FastCGI".Archived fromthe originalon 2016-03-20.— Old FastCGI home page, as it appeared when working
- Implementations
- "mod_fcgid - FastCGI interface module for Apache 2 - The Apache HTTP Server Project".Version 2.3.9. Apache Software Foundation. 2013-10-08.Retrieved2022-05-01.— Implementation for Apache httpd
- "FastCGI <fastCgi>".Internet Information Server documentation.Microsoft. 2022-04-06.Archivedfrom the original on 2022-01-27.Retrieved2022-05-01.— Implementation for Microsoft IIS
- "Proxy FastCGI Scheme Apache Module".ZenProjects. 2017-10-09.Retrieved2022-05-01.— Experimental implementation for Apache 2.x mod_proxy