In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the management of the PHP-FPM process". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the management mode of the PHP-FPM process".
This article will introduce the following:
Introduction to PHP-FPM process Management
How PHP-FPM communicates with Web servers such as Nginx
Let's first talk about the process model of PHP-FPM. PHP-FPM uses the Master/Worker process model. When PHP-FPM starts, it reads the configuration file and creates a Master process and several Worker processes (specifically, several Worker processes are determined by the number configured in php-fpm.conf). The Worker process is fork by the Master process.
The role of Master process and Worker process:
Master process: responsible for managing Worker process, listening port
Worker process: processing business logic
There are three ways of PHP-FPM process management: dynamic (Dynamic), static (Static) and on-demand (Ondemand), which will be described below.
Dynamic (Dynamic) in this way, a certain number of Worker processes are created when PHP-FPM starts. As the number of requests increases, the number of Worker processes increases dynamically; when the number of requests falls, the Worker processes that have just been dynamically created are destroyed. In this way, if the maximum number of processes configured is too large, when the number of requests increases, there will be a large number of Worker processes, which will switch frequently between processes, wasting a lot of CPU resources.
The following three parameters configure the number of Worker processes:
Pm.start_servers: the number of starting php-fpm processes in dynamic mode.
Pm.min_spare_servers: the minimum number of php-fpm processes in dynamic mode.
Pm.max_spare_servers: the maximum number of php-fpm processes in dynamic mode.
In Static mode, the number of Worker processes specified in the configuration file is created when PHP-FPM starts, and does not increase or decrease according to the number of requests. Because each Worker process started by PHP-FPM can only process one request at a time, in this way, when the request grows, there will be a wait situation.
The following parameter configures the number of Worker processes: pm.max_children: the number of php-fpm processes opened in static mode.
On demand (Ondemand) in this way, when PHP-FPM starts, the Worker process is not created, and when the request arrives, the Master process fork the child process. In this mode, if the number of requests is large, the Master process will be very busy and will take up a lot of CPU time. Therefore, this model is not suitable for high-traffic environment.
In the Nginx+PHP-FPM architecture, how does the Web server communicate with PHP-FPM?
When a user requests an http address, Nginx receives the request and forwards the request to PHP-FPM,PHP-FPM. After receiving the request, the request is forwarded to an idle Worker process. When the Worker process is finished, the result will be returned to Nginx,Ngixn and then the content will be returned to the user.
Thank you for your reading, the above is the content of "the Management of PHP-FPM process". After the study of this article, I believe you have a deeper understanding of the management of PHP-FPM process, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.