ä¸ãCPU使ç¨çå ¶å®å°±æ¯è¿è¡çç¨åºå ç¨çCPUèµæºï¼è¡¨ç¤ºä½ çæºå¨å¨æ个æ¶é´ç¹çè¿è¡ç¨åºçæ åµã使ç¨çè¶é«ï¼è¯´ææºå¨å¨è¿ä¸ªæ¶é´ä¸è¿è¡äºå¾å¤ç¨åºï¼åä¹è¾å°ã使ç¨ççé«ä½ä¸ä½ çCPU强弱æç´æ¥å ³ç³»ãèä¸CPUåå åå ç¨æ¯è·ä½ çèæ¬æé©çã èæ¬å¤æï¼å ç¨çå°±å¤ã
äºãæ¥éª¤
æ¹æ³ä¸ï¼
ã1ãé¦å ä½ éè¦ç¨åæµå·¥å ·ï¼æ¯å¦webbenchï¼æç»æ¨¡æ请æ±ï¼ å¨åæµæé´æ¯ç§è¿è¡ps aux |grep php-fpmä¸æ¬¡ï¼æç»æè®°å½å¨æ件ä¸ã
ã2ãçåæµç»æåï¼å¯ä»¥éè¿åæç»è®¡è¿ä¸ªæ件ï¼ç»æ第ä¸åæ¯cpuå ç¨ï¼ç¬¬ååæ¯å åå ç¨ï¼ï¼ç¶åå°±å¯ä»¥ç»å¶åºphp-fpmè¿ç¨çcpu,å åå ç¨äºã
æ¹æ³äºï¼
å¦æå¨æä¸åå·ç设å¤ä¸è¿è¡è¿æµè¯ï¼ç°å¨éè¦è§åä¸ä¸æ¬¡æµè¯ä»»å¡éè¦çCPUèµæºï¼æè å¨åä¸åå·ç设å¤ä¸ï¼å¯¹æ¯ä¸ååºç¨ç±»åãåä¸åºç¨ä¸åçæ¬ä¹é´çå·®å¼ï¼å¯ä»¥éç¨ç®åä¼°ç®ã
1. 计ç®æ¹æ³
CPU个æ°xå©ç¨ç/ååé=CPU个æ°xå©ç¨ç/ï¼äº¤æç¬æ°/ç§ï¼=CPU个æ°xå©ç¨çxç§/交æç¬æ°=æ¯ç¬äº¤ææ¶èçCPUæç»äºä¸ç§éã
2. 举ä¾è¯´æ
å设æåºç¨å¨ä¸å°8æ ¸æå¡å¨ä¸è¿è¡ï¼å½æ¯ç§å¤ç100ç¬äº¤æçæ
åµä¸ï¼CPUå©ç¨ç为70%ãæ¤æ¶CPU个æ°xå©ç¨ç=5.6ã
æ¯ç¬äº¤ææ¶èä¸ç§éCPUç个æ°=5.6/100=0.056ã
å设ä¸æ¬¡æµè¯éè¦æµè¯ååé为æ¯ç§200ç¬äº¤æï¼å¤§çº¦è¦æ±CPUå©ç¨çå¨50%å·¦å³ãåéè¦ç»æµè¯æå¡å¨å¤§çº¦çCPU个æ°ä¸ºï¼0.056x200/0.5=22.4ãè³äºè¿ä¸ª22.4Cçæå¡å¨è½ä¸è½è¾¾å°æ¯ç§200ç¬äº¤æçè½åï¼æ¯å¦ä¸åäºã