FastCgi with php-fpm

FASTCGI: A protocol for communication between a WEB server and a handler, which is an improvement of CGI.

Repeated loading of CGI programs is the main reason for the low performance of CGI. If the CGI program is kept in memory and is scheduled by the FastCGI process manager, it can provide good performance, scalability, Fail-Over characteristics, etc.

FASTCGI is a resident CGI that can run all the time and does not take time to fork a process when a request arrives.

FastCGI is a language-independent, scalable architecture open extension to CGI that keeps the CGI interpreter process in memory for high performance.

In general, the entire workflow of FastCGI is like this:

1. Load FastCGI Process Manager (IIS ISAPI or Apache Module) when Web Server starts

2. The FastCGI process manager initializes itself, starts multiple CGI interpreter processes (multiple php-cgi can be seen) and waits for the connection of the WebServer.

3. When a client request arrives at the Web Server, the FastCGI process manager selects and connects to a CGI interpreter. The web server sends CGI environment variables and standard input to the FastCGI subprocess php-cgi.

4. After the FastCGI subprocess completes processing, it returns the standard output and error information from the same connection to the Web Server. The request is processed when the FastCGI child process closes the connection. The FastCGI child process then waits for and handles the next connection from the FastCGI process manager (running in the Web Server). In CGI mode, php-cgi exits here.

PHP-fpm

Fastcgi is an upgraded version of CGI, a language-independent protocol used to communicate with programs (such as PHP, Python, Java) and Web servers (Apache2, Nginx). In theory, programs written in any language can provide Web services through Fastcgi .
The characteristic of Fastcgi is that multiple requests will be completed in turn in a process to achieve the purpose of improving efficiency. Most Fastcgi implementations will maintain a process pool.

PHP-fpm is an implementation of Fastcgi for PHP, which is responsible for managing a process pool to handle requests from web servers. Currently, PHP-fpm is built into PHP.

But PHP-fpm is just a "PHP Fastcgi Process Manager", it still calls the PHP interpreter itself to process the request, the PHP interpreter (under Windows) is php-cgi.exe.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324812067&siteId=291194637
Recommended