Nginx reverse proxy function - implement FastCGI real case

           Nginx reverse proxy function - implement FastCGI real case

                                          Author: Yin Zhengjie

Copyright: original works, declined to reprint! Otherwise held liable.

 

 

 

A .FastCGI Overview

1> .CGI origin

  The first Web server can simply response sent by the browser HTTP request, HTML file and stored on a server returns to the browser, which is a static html file, but later as the site features more and increase website development complex that appears dynamic technologies such as PHP ( 1995 Nian), the Java ( 1995 ), Python ( 1991 ) language development site, but nginx / the Apache server and can not run php, java such files directly. 

  apache way to achieve is patched, but by the lack of third-party nginx-based protocol, that is, through a specific protocol client requests to deal with third-party services, third-party server creates a new process to handle user requests, processing after completing the data is returned to the recovery process and Nginx, in the last nginx returned to the client, and that this agreement is the common gateway Interface (common gateway interface, referred to as CGI), CGI (agreement) is an interface standard between a web server and an external application , is the transfer of information between the standardized interface cgi program and a web server.

2> Why FastCGI 

  CGI protocol solves the problem of communication between language parser and seb server, but it's inefficient because every web server will receive a request to create a CGI process, PHP parser will parse the php.ini file to initialize the environment , and then request the end of the shutdown process, to perform these operations for each CGI process will be created, so the efficiency is very low, CGI and FastCGI is used to improve performance, each FastCGI process does not close off after processing requests, this process is reserved, so that the process can handle multiple requests. In this case each request do not have to re-create a process, and greatly enhance the processing efficiency.

3> What is PHP-FPM

  PHP-FPM (FastCGI Process Manager: FastCGI Process Manager) is a realization of Fastcgi procedures, and provide process management functions. Processes including master process and worker processes. Only one master process, responsible for monitoring port, accepts requests from the webserver. generally have a plurality of worker processes, each process will be embedded in a PHP parser PHP code processing.

 

two.

 

three.

 

Guess you like

Origin www.cnblogs.com/yinzhengjie/p/12111179.html