当前位置:网站首页>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 .
边栏推荐
- 204. Count prime
- Nodejs (01) - introductory tutorial
- 多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
- leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
- 2022-2028 global solid phase extraction column industry research and trend analysis report
- Multifunctional web file manager filestash
- Torch learning notes (2) -- 11 common operation modes of tensor
- SQL injection -day16
- [combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
- PHP determines which constellation it belongs to today
猜你喜欢
English grammar_ Adjective / adverb Level 3 - multiple expression
22.2.14 -- station B login with code -for circular list form - 'no attribute' - 'needs to be in path selenium screenshot deviation -crop clipping error -bytesio(), etc
my. INI file not found
FBI warning: some people use AI to disguise themselves as others for remote interview
How many convolution methods does deep learning have? (including drawings)
2022-2028 global marking ink industry research and trend analysis report
Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
Getting started with JDBC
Mature port AI ceaspectus leads the world in the application of AI in terminals, CIMC Feitong advanced products go global, smart terminals, intelligent ports, intelligent terminals
Pan for in-depth understanding of the attention mechanism in CV
随机推荐
After nohup NPM start &, close the shell window directly, and the process closes accordingly
Golang string (string) and byte array ([]byte) are converted to each other
Torch learning notes (4) -- torch's dynamic calculation diagram
Coordinate layer conversion tool (video)
Typescript official website tutorial
189. Rotation array
SSH 远程执行命令简介
[combinatorics] generating function (positive integer splitting | basic model of positive integer splitting | disordered splitting with restrictions)
组策略中开机脚本与登录脚本所使用的用户身份
2022-2028 global aircraft head up display (HUD) industry research and trend analysis report
2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report
Zhengda futures news: soaring oil prices may continue to push up global inflation
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
Su embedded training - Day10
4. Load balancing and dynamic static separation
This diversion
What kind of experience is it when the Institute earns 20000 yuan a month?
English语法_名词 - 分类
042. (2.11) do it when it's time to do it