当前位置:网站首页>Max of PHP FPM_ Some misunderstandings of children
Max of PHP FPM_ Some misunderstandings of children
2022-07-03 18:42:00 【Brother Xing plays with the clouds】
Now? nginx + fpm Basically become the mainstream configuration , What we pay more attention to is pm.max_chindren Configuration of
First , We focus on a premise setting : pm = static/dynamic,
This option is identification fpm Generation mode of subprocess :
static : It means that fpm The runtime directly fork Out pm.max_chindren individual worker process ,
dynamic: Express , Runtime fork Out start_servers A process , As the load increases , Dynamic adjustment , Not more than max_children A process .
Generally recommended static, The advantage is that there is no need to dynamically judge the load , Lifting performance , The disadvantage is to occupy more system memory resources .
The above tells us max_chindren Representative worker The number of processes . It is generally believed that , The more this configuration is, the more concurrency it can handle at the same time , This is a big mistake :
1) Look at the fpm Related source code , Manage processes and worker The process is through pipe For data communication . So there are many processes , Increase the overhead of process management , Overhead of system process switching , More importantly , Can be executed concurrently fpm The process will not exceed cpu Number . By opening more worker To increase the number of qps, It's a misunderstanding , I won't say that you have opened several more processes , Just a few more cpu To deal with it .
2) but worker Less progress , If server If you are busy , It leads to nginx Type the data to fpm When , Find all woker All at work , There is no free worker To accept the request , Which leads to 502.
that worker How to configure numbers ?
Theoretically woker Number of processes =cpu The number of is the most reasonable , But because of the 2 Reason for point , Maybe each worker Didn't finish processing the request , such , It will appear frequently 502 了 . But ask more , Just say avoid 502, Temporarily put the request hang live , But this is only the way to alleviate , In fact, this will not increase the concurrency of the system , And it will increase the load of the system , therefore , Set a reasonable worker Number is more important .
Martial arts in the world , Fast break not only , Only try to improve the efficiency of the program , Minimize the time of a single request , such , Single worker The processing time of is shortened , There are naturally more requests that can be processed in unit time .
Then you can pass each worker Estimate the number of requests processed per unit time max_children The number of . Suppose the processing time of the largest request is 100ms Inside , And in the 100ms At the same time 100 Please come here , In theory, it needs to be configured 100 individual worker process , First give the request to hang live .
But the biggest request time may be affected by many external conditions , Not a good estimate , In fact, there is a shortcut , To configure your max_children Count , It's that you put max_childnren Set to a larger value , After a period of stable operation , Observe fpm Of status Inside max active processes How much is the , And then put max_children If the configuration is larger than him ok 了 .
I hope these articles can help you .
边栏推荐
- Sensor 调试流程
- Nodejs (01) - introductory tutorial
- 平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
- MySQL duplicate check
- Torch learning notes (4) -- torch's dynamic calculation diagram
- Computer graduation project PHP library book borrowing management system
- Install apache+php+mysql+phpmyadmin xampp and its error resolution
- [Godot] add menu button
- After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
- Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
猜你喜欢

235. 二叉搜索树的最近公共祖先【lca模板 + 找路径相同】

leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】

CTO and programmer were both sentenced for losing control of the crawler

English grammar_ Adjective / adverb Level 3 - multiple expression

What kind of experience is it when the Institute earns 20000 yuan a month?

SQL: special update operation

12、 Service management
![[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*](/img/e8/67961bf8a589869bde2a0aa3e09605.jpg)
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*

Prototype inheritance..

What problems can cross-border e-commerce sellers solve with multi platform ERP management system
随机推荐
Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
Torch learning notes (4) -- torch's dynamic calculation diagram
leetcode:556. 下一个更大元素 III【模拟 + 尽可能少变更】
Mysql45 lecture learning notes (II)
2022-2028 global solid phase extraction column industry research and trend analysis report
SSH 远程执行命令简介
Install apache+php+mysql+phpmyadmin xampp and its error resolution
CV in transformer learning notes (continuously updated)
[Godot] add menu button
Sensor debugging process
虚拟机和开发板互Ping问题
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
The vscode code is automatically modified to a compliance code when it is formatted and saved
Redis cache avalanche, penetration, breakdown
2022-2028 global petroleum pipe joint industry research and trend analysis report
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
What kind of experience is it when the Institute earns 20000 yuan a month?
Self executing function