The relationship and difference between CGI, FASTCGI, and PHP-FPM.

What is CGI?
The early wab server can only handle simple static wab files, but with With the development of technology, dynamic languages ​​such as PHP and Python have emerged. The PHP language is handed over to the PHP parser for processing, but how to communicate with the web server after processing?
In order to solve the communication between different language processors and web servers, the CGI protocol appeared. As long as the program is written in accordance with the CGI protocol, the communication with the language parser and the web server can be realized.
CGI protocol solves the communication problem between language parser and seb server, but its efficiency is very low. Because the web server creates a CGI process every time it receives a request, the PHP parser will parse the php.ini file, initialize the environment, and close the process when the request is over. These operations are performed for each created CGI process. So the efficiency is very low.

What is FastCGI?
FastCGI is used to improve CGI performance. FastCGI processes the request each time The process will not be closed afterwards. Instead, keep this process so that it can handle multiple requests. In this way, there is no need to recreate a process for each request. Greatly improve the processing efficiency.

What is PHP-FPM?
PHP-FPM (FastCGI Process Manager: FastCGI Process Manager) is a program that implements Fastcgi and provides process management functions. The process includes the master process and the worker process. There is only one master process, which is responsible for listening on the port and accepting requests from the web server. There are usually multiple worker processes, and a PHP parser is embedded in each process to process PHP code.

What is CGI?

Early wab servers can only handle simple static wab files, but with the development of technology, dynamic languages ​​such as PHP and Python have emerged. The PHP language is handed over to the PHP parser for processing, but how to communicate with the web server after processing?

In order to solve the communication between different language processors and web servers, the CGI protocol appeared. As long as the program is written in accordance with the CGI protocol, the communication with the language parser and the web server can be realized.

CGI protocol solves the communication problem between language parser and seb server , But its efficiency is very low. Because the web server creates a CGI process every time it receives a request, the PHP parser will parse the php.ini file, initialize the environment, and close the process when the request is over. These operations are performed for each created CGI process. So the efficiency is very low.


What is FastCGI?

FastCGI is used to improve CGI performance. FastCGI will not shut down the process every time it processes the request. Instead, keep this process so that it can handle multiple requests. In this way, there is no need to recreate a process for each request. Greatly improve the processing efficiency.


What is PHP-FPM?

PHP-FPM(FastCGI Process Manager: FastCGI Process Manager) is a program that implements Fastcgi and provides process management functions. The process includes the master process and the worker process. There is only one master process, which is responsible for listening on the port and accepting requests from the web server. There are usually multiple worker processes, and a PHP parser is embedded in each process to process PHP code.

Leave a Comment

Your email address will not be published.