PHP-FPM Detailed PHP-FPM Detailed

PHP-FPM Detailed

 

effect

PHP-FPM (PHP FastCGI Process Manager ) Italy: PHP FastCGI Process Manager to manage processes pool PHP software for web server requests accepted.
PHP-FPM PHP provides a better process management, can effectively control the memory and processes can smoothly overloading PHP configuration.

(1) Why is there php-fpm

All fpm appear because php-fastcgi appear. A good management program in order to achieve the php-fastcgi

(2) What is the php-fastcgi

php-fastcgi just a cgi program, php will parse the request and returns the result, it does not manage (and therefore did not emerge until php-fpm).

(3) Why not call php-cgi

In fact, before emergence php-fastcgi php-cgi is a presence, but its low efficiency, thus substituted php-fastcgi.

(4) that cgi fastcgi and what difference does it?

Pro, this difference is large, and when a service web-server (nginx) distributed over the request, knows that the request by matching the suffix is ​​a dynamic php request, the request will be transferred to php.

In cgi era of conservative thinking, always after a request came, to read php.ini in the basic configuration information, initializing the execution environment, every time to create a non-stop process, reads the configuration, initialization environment return data, quit the process, over time, become a tedious job to start the process of boring especially tired.

Php came when the times 5, we especially disgusted with this way of working, like lazy people desperately want to, can I make a cgi time you start the main process (master), let him read only once configured, then launch multiple worker processes (worker), when a request by master passed to the worker so you can avoid a duplication of effort. Thus a fastcgi.

(5) fastcgi so well, run out to start the worker how to do?
When the worker is not enough time, master will configure the information in the dynamic start worker, such as idle time can be recovered worker

(6) up to now still do not understand php-fpm is what?
Is a master program to manage the startup process and multiple worker processes.

PHP-FPM creates a master process control when and how HTTP requests to one or more child process handling. PHP-FPM main process also controls what
it created when (process Web applications more traffic) and destruction (child process runs too long or no longer needed)
PHP child processes. Each process in the presence of PHP-FPM process pool than the time length of a single HTTP request, may be the
processing of an HTTP request 10,50,100,500 or more.

installation

After PHP 5.3.3 php-fpm been incorporated into the core code of the php. Therefore, no separate php-fpm download and install.
To support php php-fpm, only you need to bring --enable-fpm php source code at compile time on it.

Global Configuration

In the Centos, PHP-FPM's main configuration file is /etc/php7/php-fpm.conf.

Within a specified period of time has designated sub-process fails, PHP-FPM reboot:

Configure process pool

PHP-FPM profile rest of the content is an area called the Pool Defintions. The area where the user configuration settings for each pool of PHP-FPM process. PHP-FPM process pool is a series of related PHP child processes. == is usually a PHP application process has its own a pool ==.

Centos introduction of process pool definition file at the top of PHP-FPM main configuration file:

www.conf is the default configuration file PHP-FPM process pool.

Edit save and restart PHP-FPM main processes:

PHP-FPM process configuration details pool see  http://php.net/manual/install.fpm.configuration.php

Reference Company Development Environment

Configuring the test environment is as follows:

Production environment configuration:

Forwards the request to the PHP-FPM

nginx as an example:

Think

  • [x] thinking:
    What factors concurrency server depends?

PHP-FPM maximum number of processes,the number of concurrent nginx(Nginx just act as a proxy server), memory usage, cpu overhead

QPS server (requests per second) = average number of connection requests * (1 / response time);

= Effective time concurrency * QPS;

  • solve:
  1. Plus shunt machine
    • The need to add complicated calculation machine
  2. The new stand-alone increase energy
    • Open opcache php increase memory space
    • Access caching system
    • sql optimization
    • php optimization
      ...

reference

https://segmentfault.com/a/1190000010844969

https://www.zhihu.com/question/20049768

 
Original Address https://www.cnblogs.com/followyou/p/9460058.html

effect

PHP-FPM (PHP FastCGI Process Manager ) Italy: PHP FastCGI Process Manager to manage processes pool PHP software for web server requests accepted.
PHP-FPM PHP provides a better process management, can effectively control the memory and processes can smoothly overloading PHP configuration.

(1) Why is there php-fpm

All fpm appear because php-fastcgi appear. A good management program in order to achieve the php-fastcgi

(2) What is the php-fastcgi

php-fastcgi just a cgi program, php will parse the request and returns the result, it does not manage (and therefore did not emerge until php-fpm).

(3) Why not call php-cgi

In fact, before emergence php-fastcgi php-cgi is a presence, but its low efficiency, thus substituted php-fastcgi.

(4) that cgi fastcgi and what difference does it?

Pro, this difference is large, and when a service web-server (nginx) distributed over the request, knows that the request by matching the suffix is ​​a dynamic php request, the request will be transferred to php.

In cgi era of conservative thinking, always after a request came, to read php.ini in the basic configuration information, initializing the execution environment, every time to create a non-stop process, reads the configuration, initialization environment return data, quit the process, over time, become a tedious job to start the process of boring especially tired.

Php came when the times 5, we especially disgusted with this way of working, like lazy people desperately want to, can I make a cgi time you start the main process (master), let him read only once configured, then launch multiple worker processes (worker), when a request by master passed to the worker so you can avoid a duplication of effort. Thus a fastcgi.

(5) fastcgi so well, run out to start the worker how to do?
When the worker is not enough time, master will configure the information in the dynamic start worker, such as idle time can be recovered worker

(6) up to now still do not understand php-fpm is what?
Is a master program to manage the startup process and multiple worker processes.

PHP-FPM creates a master process control when and how HTTP requests to one or more child process handling. PHP-FPM main process also controls what
it created when (process Web applications more traffic) and destruction (child process runs too long or no longer needed)
PHP child processes. Each process in the presence of PHP-FPM process pool than the time length of a single HTTP request, may be the
processing of an HTTP request 10,50,100,500 or more.

installation

After PHP 5.3.3 php-fpm been incorporated into the core code of the php. Therefore, no separate php-fpm download and install.
To support php php-fpm, only you need to bring --enable-fpm php source code at compile time on it.

Global Configuration

In the Centos, PHP-FPM's main configuration file is /etc/php7/php-fpm.conf.

Within a specified period of time has designated sub-process fails, PHP-FPM reboot:

Configure process pool

PHP-FPM profile rest of the content is an area called the Pool Defintions. The area where the user configuration settings for each pool of PHP-FPM process. PHP-FPM process pool is a series of related PHP child processes. == is usually a PHP application process has its own a pool ==.

Centos introduction of process pool definition file at the top of PHP-FPM main configuration file:

www.conf is the default configuration file PHP-FPM process pool.

Edit save and restart PHP-FPM main processes:

PHP-FPM process configuration details pool see  http://php.net/manual/install.fpm.configuration.php

Reference Company Development Environment

Configuring the test environment is as follows:

Production environment configuration:

Forwards the request to the PHP-FPM

nginx as an example:

Think

  • [x] thinking:
    What factors concurrency server depends?

PHP-FPM maximum number of processes,the number of concurrent nginx(Nginx just act as a proxy server), memory usage, cpu overhead

QPS server (requests per second) = average number of connection requests * (1 / response time);

= Effective time concurrency * QPS;

  • solve:
  1. Plus shunt machine
    • The need to add complicated calculation machine
  2. The new stand-alone increase energy
    • Open opcache php increase memory space
    • Access caching system
    • sql optimization
    • php optimization
      ...

reference

https://segmentfault.com/a/1190000010844969

https://www.zhihu.com/question/20049768

Guess you like

Origin www.cnblogs.com/php-linux/p/11516909.html
Recommended