Why is FastCGI fast?

FastCGI provides the ability to improve the performance of thousands of Perl applications that have been written for the web. - Source

and how to do it?

+6
source share
3 answers

Mark R. Brown's white paper states that one of the main advantages of FastCGI is that different requests can share the same cache, which makes practical use of caching:

Today, the most widely deployed web server APIs are based on the process pool server model. A 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 unoccupied child in a random order. The child starts the request before completion before accepting a new request. A typical server has 32 child processes, with a large server 100 or 200.

In-memory caching works very poorly in this server model because processes do not exchange memory and incoming requests are assigned randomly. For example, to store a frequently used file in memory, the server must store a copy of the file for one child, which takes up memory. When the file is modified, all children should be notified that it is complex (APIs do not provide a way to do this).

FastCGI is designed for efficient in-memory caching. Requests are routed from any child process to the FastCGI application server. The FastCGI application process maintains a cache in memory.

+10
source

β€œInstead of creating a new process for each request, FastCGI uses constant processes to process a number of requests. These processes belong to the FastCGI server, not the website server.”

- Wikipedia

+8
source

It reuses processes from the pool instead of creating a new one for each request.

+4
source

Source: https://habr.com/ru/post/891759/


All Articles