当前位置:网站首页>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 .
边栏推荐
- [leetcode周赛]第300场——6110. 网格图中递增路径的数目-较难
- leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
- ES7 - Optimization of promise
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing
- Multifunctional web file manager filestash
- Nodejs (01) - introductory tutorial
- English语法_名词 - 分类
- 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
- Computer graduation project PHP library book borrowing management system
猜你喜欢
[untitled]
2022-2028 global solid phase extraction column industry research and trend analysis report
VLAN experiment
An academic paper sharing and approval system based on PHP for computer graduation design
leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
CTO and programmer were both sentenced for losing control of the crawler
How to expand the capacity of golang slice slice
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
Torch learning notes (3) -- univariate linear regression model (self training)
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
随机推荐
Reappearance of ASPP (atlas spatial pyramid pooling) code
There are several levels of personal income tax
硬盘监控和分析工具:Smartctl
Typescript official website tutorial
How many convolution methods does deep learning have? (including drawings)
Win 11 major updates, new features love love.
Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
Day-27 database
Self executing function
Golang string (string) and byte array ([]byte) are converted to each other
Computer graduation design PHP makeup sales Beauty shopping mall
English語法_名詞 - 分類
Getting started with JDBC
2022.02.11
How to track the real-time trend of Bank of London
English grammar_ Noun classification
Torch learning notes (1) -- 19 common ways to create tensor
Unity webgl optimization
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
English grammar_ Adjective / adverb Level 3 - multiple expression