Nginx configuration file corresponds to PHP-FPM configuration file

Source: Internet
Author: User
Keywords nginx php fpm
Tags epoll
The ngin configuration file is as follows:

User nobody nobody;
Worker_processes 4; Nginx number of processes to open
Error_log Logs/error.log Notice;
PID Logs/nginx.pid;
Worker_rlimit_nofile 65535; For binding worker processes and CPUs, more than 2.4 of Linux cores are available
events{

use epoll;  worker_connections      65536; //用于定义Nginx每个进程的最大连接数   }   

The PHP-FPM configuration file is as follows:
5 //max_children is used to set the number of fastcgi processes, according to the official recommendation, less than 2GB memory server, can only open 64 processes, 4GB or more can open 200 processes.
The//rlimit_files is used to set the PHP-FPM limit on open file descriptors, which is 1024 by default.
the $//tag max_requests indicates how many requests per children are processed and is turned off, with the default setting of 500.

Ask:
1, the Nginx configuration file worker_processes and php-fpm in the relationship between Max_children?
2, the Nginx configuration file in Worker_connections and php-fpm in Rlimit_files, max_requests relationship?

Reply content:

The Ngin configuration file is as follows:

User nobody nobody;
Worker_processes 4; Nginx number of processes to open
Error_log Logs/error.log Notice;
PID Logs/nginx.pid;
Worker_rlimit_nofile 65535; For binding worker processes and CPUs, more than 2.4 of Linux cores are available
events{

use epoll;  worker_connections      65536; //用于定义Nginx每个进程的最大连接数   }   

The PHP-FPM configuration file is as follows:
5 //max_children is used to set the number of fastcgi processes, according to the official recommendation, less than 2GB memory server, can only open 64 processes, 4GB or more can open 200 processes.
The//rlimit_files is used to set the PHP-FPM limit on open file descriptors, which is 1024 by default.
the $//tag max_requests indicates how many requests per children are processed and is turned off, with the default setting of 500.

Ask:
1, the Nginx configuration file worker_processes and php-fpm in the relationship between Max_children?
2, the Nginx configuration file in Worker_connections and php-fpm in Rlimit_files, max_requests relationship?

There is no relationship at all. Ngnix as a front-office agent, it basically does not handle the request, but the request to php-fpm to deal with. In other words, Ngnix basically does not exist read-write files, databases, resources, such as IO-intensive operations, more is the routing, rewrite and other CPU-intensive operations, this time we would recommend the number of concurrent processes Ngnix set and CPU core number consistent. While PHP-FPM is the actual process of processing requests, in the process, IO operations more, in order to ensure concurrency, we will be based on the actual physical performance, as much as possible to set the number of concurrent processes. In addition, Nginx is not directly connected with each PHP-FPM processing process, but through a PHP-FPM master process for the relay, so the configuration of the process-related parameters between the basic no contact. However, the overall performance of the server has a short board effect, the performance will be poor between the two as a limitation, so both are properly configured to reflect the overall effect.

  • 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.