当前位置:网站首页>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 .
边栏推荐
- Naoqi robot summary 27
- 2022-2028 global sepsis treatment drug industry research and trend analysis report
- Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
- Change the single node of Postgres database into master-slave
- 2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]
- [combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
- How do microservices aggregate API documents? This wave of operation is too good
- shell 脚本中关于用户输入参数的处理
猜你喜欢

2022-2028 global plasmid DNA cdmo industry research and trend analysis report

Summary and Reflection on the third week of winter vacation
![[untitled]](/img/83/5a57ed90aaafde94db600246256867.jpg)
[untitled]

leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】

Opencv learning notes (continuously updated)

VLAN experiment

平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方

English语法_形容词/副词3级 - 倍数表达

Caddy server agent

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
随机推荐
Usage of laravel conditional array in
Graduation summary
leetcode:556. 下一个更大元素 III【模拟 + 尽可能少变更】
What is SQL get connection
How about the Moco model?
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
Should I be laid off at the age of 40? IBM is suspected of age discrimination, calling its old employees "dinosaurs" and planning to dismiss, but the employees can't refute it
2022-2028 global lithium battery copper foil industry research and trend analysis report
Zero length array
Redis cache avalanche, penetration, breakdown
Bidding procurement scheme management of Oracle project management system
Niuke monthly race 31 minus integer
Sepconv (separable revolution) code recurrence
2022.02.11
Compose LazyColumn 顶部添加控件
Setinterval CPU intensive- Is setInterval CPU intensive?
Zhengda futures news: soaring oil prices may continue to push up global inflation
Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
webcodecs
This diversion