FastCgi and PHP-FPM

Source: Internet
Author: User

-If the request is now/index.php, according to the configuration file, Nginx know this does not. is a static file, need to find a PHP parser to deal with, then he will make this request simple processing and handed over to the PHP parser. What data will the Nginx send to the PHP parser? URLs, query strings, POST data, HTTP headers, and so on, CGI is the protocol that specifies which data to pass, in what format, to the rear to process the request. When the Web server receives the/index.php request, it launches the corresponding CGI program, which is the parser for PHP. The PHP parser then parses the php.ini file, initializes the execution environment, then processes the request, and then returns the processed result in a format specified by the CGI, exiting the process. The Web server then returns the results to the browser. FastCgi is what FastCgi is a protocol, FASTCGI is used to improve the performance of CGI programs. So what is the performance problem with CGI programs? "The PHP parser parses the php.ini file, initializes the execution environment," and here it is. The standard CGI performs these steps for each request, so it takes longer to process each request. So how did FastCgi do it? First, FastCgi initiates a master, parses the configuration file, initializes the execution environment, and then starts multiple workers. When the request comes in, master passes it to a worker, and then immediately accepts the next request. This avoids duplication of labor, and efficiency is naturally high. And when the worker is not enough, master can pre-boot several workers according to the configuration and so on, of course, the idle worker too much, will also stop some, this improves the performance, also saves the resources. This is FastCgi's management of the process.PHP-FPM is an implementation of the FASTCGI program, is included in the official PHP. PHP interpreter is php-cgi, it is only a CGI program, can only parse the request, return the results, will not process management. So there are some programs that can dispatch the php-cgi process, such as spawn-fcgi, php-fpm separated by LIGHTHTTPD. The management object of PHP-FPM is php-cgi. PHP-CGI is just a program that explains PHP scripts, fastcgi is a protocol, PHP-FPM implements this Protocol

FastCgi and PHP-FPM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.