Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is FastCGI fast? [closed]

Tags:

perl

fastcgi

FastCGI provides a way to improve the performance of the thousands of Perl applications that have been written for the Web. -Source

and how does it do that?

like image 586
Chankey Pathak Avatar asked Jun 30 '11 18:06

Chankey Pathak


People also ask

Which is better FastCGI or FPM?

FPM processes requests faster (more than 30%) compared to FastCGI, which also allows it to process more than 30% more requests at a time than FastCGI.

Is FastCGI fast?

FastCGI is a fast, open, and secure Web server interface that solves the performance problems inherent in CGI, without introducing the overhead and complexity of proprietary APIs (Application Programming Interfaces).

What is the difference between CGI and FastCGI?

What makes a difference from CGI is that with FastCGI the running process of the application lasts longer and it is not immediately terminated. After the application finishes processing and returns the output data, the process is not terminated and is being used for processing further requests.


2 Answers

Mark R. Brown's whitepaper on the subject claims that one of the primary benefits of FastCGI is that different requests can share a single cache, making caching practical:

Today's most widely deployed Web server APIs are based on a pool-of-processes server model. The Web server consists of a parent process and a pool of child processes. Processes do not share memory. An incoming request is assigned to an idle child at random. The child runs the request to completion before accepting a new request. A typical server has 32 child processes, a large server has 100 or 200.

In-memory caching works very poorly in this server model because processes do not share memory and incoming requests are assigned to processes at random. For instance, to keep a frequently-used file available in memory the server must keep a file copy per child, which wastes memory. When the file is modified all the children need to be notified, which is complex (the APIs don't provide a way to do it).

FastCGI is designed to allow effective in-memory caching. Requests are routed from any child process to a FastCGI application server. The FastCGI application process maintains an in-memory cache.

like image 107
WCWedin Avatar answered Oct 31 '22 11:10

WCWedin


"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."

-- Wikipedia

like image 39
Swift Avatar answered Oct 31 '22 10:10

Swift