This article includes a list of general references, but it lacks sufficient corresponding inline citations. (June 2010)
FastCGI is a
Common Gateway Interface (CGI) is a protocol for interfacing external applications to web servers. CGI applications run in separate processes, 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 overhead 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,
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.
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 variable information and the page request to a FastCGI process over either a Unix domain socket, a named pipe, or a Transmission 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 the end user. The connection may be closed at the end of a response, but both web server and 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 multiple requests concurrently can be done in several ways: by using one connection with internal multiplexing (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 (
Web servers that implement FastCGI
- Note: unless stated, completeness of FastCGI implementation is unknown
- Apache HTTP Server (partial)
- Implemented by mod_fcgid. This module used to be third-party, but was granted to The Apache Software Foundation (ASF) as an Apache Server subproject in 2009, shepherded by Chris Darroch. It only supports Unix domain sockets, no TCP sockets.
- A third-party module mod_fastcgi is also being used. For a while, this module no longer compiled properly under Apache 2.4.x, although that problem has been solved with a fork of the original project.
- Multiplexing of requests through one connection is prohibited by Apache 1.x design, so this isn't supported
- In Apache 2.4, mod_proxy_fcgi was added, supporting TCP FastCGI servers.
- Loadbalancing FastCGI support
- Supports chrooted FastCGI servers
- Kerio WebSTAR
- LiteSpeed Web Server
- Microsoft IIS
- Oracle iPlanet Web Server
- OpenBSD's httpd(8)
- Open Market web server
- Resin web and application server
- Roxen web server
- ShimmerCat web server
- Zeus Web Server
Language bindings for its API
FastCGI can be implemented in any language that supports
- Lazarus Free Pascal
- C, C++
- Chicken Scheme
- Common Lisp
- Guile Scheme
- VSI BASIC for OpenVMS
- PHP (via php-fpm, or HipHop for PHP)
- Smalltalk: FasTalk and Dolphin Smalltalk
- Vala (via C bindings)
- Xojo (formerly Realbasic, REAL Studio)
Recent frameworks such as Ruby on Rails, Catalyst, Django, Kepler and Plack allow use with either the embedded interpreters (mod_ruby, mod_perl, mod_python or mod_lua, for example), or FastCGI.
- ^ "FastCGI Specification". Open Market, Inc. 1996. Archived from the original on 19 January 2016.
- ^ "FastCGI:A High-Performance Web Server Interface". Open Market, Inc. 1996. Archived from the original on 1 October 2010.
- ^ Heinlein, Paul (1 November 1998). "FastCGI: Persistent Applications for Your Web Server". Linux Journal. Retrieved 4 October 2010.
- ^ 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 from the original on 2010-02-08. Retrieved 2006-02-21.
- ^ Caddy User Guide – FastCGI
- ^ FastCGI for Cherokee
- ^ FastCGI howto for Hiawatha
- ^ a b FastCGI Support in Jetty
- ^ FastCGI for Lighttpd
- ^ "FastCGI Extension for IIS6.0 – RTM". FastCGI for IIS. Microsoft. 2008-02-28. Retrieved 2008-02-29.
- ^ "FastCGI Nginx module ngx_http_fastcgi_module". nginx.org. NGINX, Inc. Retrieved 20 June 2021.
- ^ OpenBSD's httpd(8) initial commit
- ^ "Technical sheet". Archived from the original on 2018-01-21. Retrieved 2016-09-19.
- ^ Application Libraries, Development Kits
- ^ Matreshka
- ^ 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 (for AnyEvent-based applications), FCGI::EV (for EV-based applications), CGI::Fast (Perl CGI-like interface for FastCGI), FCGI::Client (a FastCGI client library), and Net::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 is fastcgi, and fastcgi-client is a client implementation.
- ^ REAL Studio Web Edition, builds web apps called via FastCGI Archived 2011-02-08 at the Wayback Machine
- "FastCGI.com Archives". Retrieved 2022-05-01. — fork/mirror of down FastCGI website
- Mark R. Brown (29 April 1996). "FastCGI Specification". Document version 1.0. Open Market, Inc. Retrieved 2022-05-01.
- "FastCGI". Archived from the original on 2016-03-20. — Old FastCGI home page, as it appeared when working
- "mod_fcgid - FastCGI interface module for Apache 2 - The Apache HTTP Server Project". Version 2.3.9. Apache Software Foundation. 2013-10-08. Retrieved 2022-05-01. — Implementation for Apache httpd
- "FastCGI <fastCgi>". Internet Information Server documentation. Microsoft. 2022-04-06. Archived from the original on 2022-01-27. Retrieved 2022-05-01. — Implementation for Microsoft IIS
- "Proxy FastCGI Scheme Apache Module". ZenProjects. 2017-10-09. Retrieved 2022-05-01. — Experimental implementation for Apache 2.x mod_proxy