{"id":33951,"date":"2026-10-29T18:00:00","date_gmt":"2026-10-29T10:00:00","guid":{"rendered":"https:\/\/cn.hostease.com\/blog\/?p=33951"},"modified":"2026-10-24T14:28:46","modified_gmt":"2026-10-24T06:28:46","slug":"php-fpm-cpu-pm-max-children","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/blog\/guides\/php-fpm-cpu-pm-max-children\/","title":{"rendered":"PHP-FPM \u8fdb\u7a0b\u5360\u6ee1 CPU\uff1apm.max_children \u4e0e\u6162\u65e5\u5fd7\u5b9a\u4f4d\u5361\u987f\u6e90\u5934"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/php-fpm-cpu-pm-max-children-cover.webp\" alt=\"PHP-FPM \u8fdb\u7a0b\u4e0e CPU \u8d44\u6e90\u5173\u7cfb\u5c01\u9762\u914d\u56fe\" loading=\"lazy\" \/><\/p>\n<h2>\u7f51\u7ad9\u7a81\u7136\u5361\u6b7b\uff0cCPU \u88ab PHP-FPM \u5360\u6ee1\u600e\u4e48\u529e<\/h2>\n<p>\u4e0b\u5348\u4e09\u70b9\uff0c\u5916\u8d38\u7ad9\u8ba2\u5355\u9ad8\u5cf0\uff0c\u5ba2\u6237\u53cd\u9988\u9875\u9762\u8f6c\u5708\u6253\u4e0d\u5f00\u3002\u4f60\u767b\u5f55\u670d\u52a1\u5668\u6572\u4e0b <code>top<\/code>\uff0c\u53d1\u73b0 CPU \u5df2\u7ecf 100%\uff0c\u8fdb\u7a0b\u5217\u8868\u91cc\u4e00\u6392 <code>php-fpm: pool www<\/code> \u5168\u90e8\u5904\u4e8e\u8fd0\u884c\u72b6\u6001\uff0c\u91cd\u542f\u670d\u52a1\u540e\u597d\u5341\u5206\u949f\uff0c\u95ee\u9898\u53c8\u56de\u6765\u4e86\u3002\u8fd9\u79cd\u60c5\u51b5\u8bf4\u660e\u4e0d\u662f\u5355\u6b21\u6545\u969c\uff0c\u800c\u662f\u8bf7\u6c42\u5904\u7406\u80fd\u529b\u88ab\u8017\u5c3d\u4e86\uff1a\u8fdb\u6765\u7684\u8bf7\u6c42\u6392\u7740\u961f\uff0c\u6bcf\u4e00\u4e2a\u90fd\u5728\u7b49\u524d\u4e00\u4e2a\u91ca\u653e\u8fdb\u7a0b\u3002\u672c\u6587\u4f1a\u5e2e\u52a9\u4f60\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u2014\u2014\u5148\u786e\u8ba4\u8fdb\u7a0b\u73b0\u573a\uff0c\u518d\u7b97\u6e05 <code>pm.max_children<\/code> \u8fd9\u9053\u5bb9\u91cf\u9898\uff0c\u6700\u540e\u7528\u6162\u65e5\u5fd7\u628a\u771f\u6b63\u62d6\u6162\u8bf7\u6c42\u7684\u90a3\u884c\u4ee3\u7801\u627e\u51fa\u6765\u3002\u6574\u4e2a\u6392\u67e5\u8fc7\u7a0b\u4e0d\u9700\u8981\u66f4\u6362\u670d\u52a1\u5668\uff0c\u591a\u6570\u60c5\u51b5\u4e0b\u6539\u51e0\u884c\u914d\u7f6e\u5c31\u80fd\u6062\u590d\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<h2>\u5148\u770b\u73b0\u573a\uff1a\u4e09\u4e2a\u547d\u4ee4\u786e\u8ba4 PHP-FPM \u662f\u4e0d\u662f\u771f\u7684\u6ee1\u8f7d<\/h2>\n<p>\u52a8\u624b\u6539\u914d\u7f6e\u4e4b\u524d\uff0c\u5148\u82b1\u4e24\u5206\u949f\u786e\u8ba4\u74f6\u9888\u786e\u5b9e\u5728 PHP-FPM\uff0c\u800c\u4e0d\u662f MySQL \u6216\u78c1\u76d8 IO\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u67e5\u770b PHP-FPM \u8fdb\u7a0b\u6570\u91cf\u4e0e CPU \u5360\u7528\nps aux --sort=-%cpu | grep php-fpm | head -15\n\n# \u7edf\u8ba1\u5f53\u524d php-fpm \u5de5\u4f5c\u8fdb\u7a0b\u603b\u6570\uff08\u5bf9\u6bd4 pm.max_children \u4e0a\u9650\uff09\nps aux | grep -c &quot;[p]hp-fpm: pool&quot;\n\n# \u67e5\u770b\u76d1\u542c\u961f\u5217\u662f\u5426\u6709\u5806\u79ef\nnetstat -anp | grep 9000 | grep -c WAIT\n<\/code><\/pre>\n<p>\u5224\u65ad\u6807\u51c6\u5f88\u76f4\u63a5\uff1a\u5982\u679c\u5de5\u4f5c\u8fdb\u7a0b\u6570\u5df2\u7ecf\u7b49\u4e8e <code>pm.max_children<\/code>\uff0c\u5e76\u4e14\u6bcf\u4e2a\u8fdb\u7a0b CPU \u63a5\u8fd1 100%\uff0c\u8bf4\u660e\u8fdb\u7a0b\u6c60\u88ab\u5360\u6ee1\uff0c\u65b0\u8bf7\u6c42\u53ea\u80fd\u6392\u961f\u3002\u6b64\u65f6\u518d\u53bb\u770b <code>\/var\/log\/php*-fpm.log<\/code>\uff0c\u5982\u679c\u51fa\u73b0 <code>server reached pm.max_children setting (50)<\/code> \u8fd9\u6837\u7684\u8b66\u544a\uff0c\u5c31\u57fa\u672c\u53ef\u4ee5\u9501\u5b9a\u95ee\u9898\u2014\u2014\u8fd9\u4e2a\u8b66\u544a\u8868\u793a\u961f\u5217\u66fe\u7ecf\u6ee1\u8fc7\uff0c\u540e\u9762\u5230\u8fbe\u7684\u8bf7\u6c42\u88ab\u8feb\u7b49\u5f85\u751a\u81f3\u88ab\u4e22\u5f03\uff0c\u7528\u6237\u770b\u5230\u7684\u5c31\u662f\u957f\u65f6\u95f4\u8f6c\u5708\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\uff1a\u8fdb\u7a0b\u6570\u6ca1\u5230\u4e0a\u9650\u4f46 CPU \u4f9d\u7136\u5f88\u9ad8\uff0c\u8fd9\u65f6\u5361\u987f\u6765\u81ea\u67d0\u4e2a\u811a\u672c\u5728\u6b7b\u5faa\u73af\u6216\u6267\u884c\u91cd\u578b\u67e5\u8be2\uff0c\u9760\u52a0\u8fdb\u7a0b\u89e3\u51b3\u4e0d\u4e86\uff0c\u5fc5\u987b\u9760\u6162\u65e5\u5fd7\u5b9a\u4f4d\u3002<\/p>\n<h2>\u7b97\u6e05\u5bb9\u91cf\u9898\uff1apm.max_children \u5230\u5e95\u8be5\u8bbe\u591a\u5c11<\/h2>\n<p><code>pm.max_children<\/code>\uff08\u8fdb\u7a0b\u7ba1\u7406\u5668\u5141\u8bb8\u7684\u6700\u5927\u5b50\u8fdb\u7a0b\u6570\uff09\u51b3\u5b9a\u4e86 PHP-FPM \u540c\u4e00\u65f6\u523b\u6700\u591a\u80fd\u5e76\u884c\u5904\u7406\u591a\u5c11\u4e2a\u8bf7\u6c42\u3002\u8bbe\u5c0f\u4e86\u8bf7\u6c42\u6392\u961f\u3001\u9ad8\u5cf0\u5361\u987f\uff1b\u8bbe\u5927\u4e86\u6bcf\u4e2a\u8fdb\u7a0b 30-80MB \u7684\u5185\u5b58\u4f1a\u6491\u7206\u7269\u7406\u4e0a\u9650\uff0c\u670d\u52a1\u5668\u53cd\u800c\u66f4\u6162\u3002\u5f88\u591a\u4eba\u5361\u987f\u540e\u7b2c\u4e00\u53cd\u5e94\u662f\u628a\u8fd9\u4e2a\u503c\u7ffb\u500d\uff0c\u7ed3\u679c\u7b2c\u4e8c\u5929\u5185\u5b58\u7206\u4e86\u3002<\/p>\n<p>\u6b63\u786e\u7684\u7b97\u6cd5\u53ea\u6709\u4e00\u6761\u516c\u5f0f\uff1a<\/p>\n<pre><code>pm.max_children = \u53ef\u5206\u914d\u7ed9 PHP \u7684\u603b\u5185\u5b58 \u00f7 \u5355\u4e2a\u8fdb\u7a0b\u5e73\u5747\u5185\u5b58\n<\/code><\/pre>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff1a\u4e00\u53f0 4GB \u5185\u5b58\u7684 <a href=\"https:\/\/cn.hostease.com\/vps\/\">VPS<\/a> \u4e0a\u8dd1\u7740 WordPress \u7ad9\uff0c\u7cfb\u7edf\u548c MySQL \u56fa\u5b9a\u5360\u7528 1.5GB\uff0c\u7559\u7ed9 PHP \u7ea6 2.5GB\u3002\u5148\u5728\u9ad8\u5cf0\u671f\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u7b97\u5355\u8fdb\u7a0b\u5e73\u5747\u5185\u5b58\uff1a<\/p>\n<pre><code class=\"language-bash\">ps --no-headers -o rss -C php-fpm | awk '{sum+=$1; n++} END {printf &quot;\u5e73\u5747\u5355\u8fdb\u7a0b\u5185\u5b58: %.0f MB\\n&quot;, sum\/n\/1024}'\n<\/code><\/pre>\n<p>\u5047\u8bbe\u6d4b\u51fa\u5355\u8fdb\u7a0b\u5e73\u5747 60MB\uff0c\u90a3\u4e48 <code>2.5GB \u00d7 1024 \u00f7 60 \u2248 42<\/code>\uff0c\u5b9e\u9645\u914d\u7f6e\u5efa\u8bae\u7559 20% \u4f59\u91cf\uff0c\u5199\u6210 34 \u5de6\u53f3\u3002\u5bf9\u5e94\u7684\u8fdb\u7a0b\u6c60\u914d\u7f6e\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<pre><code class=\"language-ini\">[www]\npm = dynamic\npm.max_children = 34\npm.start_servers = 8\npm.min_spare_servers = 4\npm.max_spare_servers = 12\n<\/code><\/pre>\n<p>\u4e09\u4e2a spare \u53c2\u6570\u63a7\u5236\u95f2\u7f6e\u8fdb\u7a0b\u7684\u4f38\u7f29\u533a\u95f4\uff1a<code>start_servers<\/code> \u662f\u542f\u52a8\u8fdb\u7a0b\u6570\uff0c<code>min_spare_servers<\/code> \u4fdd\u8bc1\u7a81\u53d1\u6d41\u91cf\u6709\u7a7a\u95f2\u8fdb\u7a0b\u63a5\u5355\uff0c<code>max_spare_servers<\/code> \u9632\u6b62\u4f4e\u5cf0\u671f\u767d\u5360\u5185\u5b58\u3002\u518d\u914d\u5408 <code>pm.max_requests = 500<\/code> \u5b9a\u671f\u91cd\u542f\u8fdb\u7a0b\uff0c\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u7d2f\u79ef\u3002<\/p>\n<p>\u5185\u5b58\u5145\u8db3\u7684\u5927\u578b\u7ad9\u70b9\u53ef\u4ee5\u8003\u8651 <code>pm = static<\/code>\uff0c\u628a\u8fdb\u7a0b\u6570\u56fa\u5b9a\u5728\u7b97\u597d\u7684\u503c\u4e0a\u3002\u56fa\u5b9a\u8fdb\u7a0b\u6c60\u7701\u53bb\u4e86\u52a8\u6001fork\u7684\u5f00\u9500\uff0c\u54cd\u5e94\u5ef6\u8fdf\u66f4\u5e73\u7a33\uff0c\u4ee3\u4ef7\u662f\u4f4e\u5cf0\u671f\u4e5f\u5360\u7740\u540c\u6837\u7684\u5185\u5b58\u2014\u2014\u5bf9\u4e8e\u6d41\u91cf\u7a33\u5b9a\u7684\u7535\u5546\u7ad9\uff0c\u8fd9\u662f\u503c\u5f97\u7684\u4ea4\u6362\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/php-fpm-capacity-formula.webp\" alt=\"pm.max_children \u5185\u5b58\u5bb9\u91cf\u6743\u8861\u793a\u610f\u56fe\" loading=\"lazy\" \/><\/p>\n<h2>\u6253\u5f00\u6162\u65e5\u5fd7\uff1a\u628a\u62d6\u6162\u8bf7\u6c42\u7684\u90a3\u884c\u4ee3\u7801\u63ea\u51fa\u6765<\/h2>\n<p>\u8c03\u597d\u8fdb\u7a0b\u6570\u53ea\u662f\u6cbb\u6807\u3002\u5982\u679c\u67d0\u4e2a\u63d2\u4ef6\u91cc\u7684 SQL \u67e5\u8be2\u8981\u8dd1 8 \u79d2\uff0c34 \u4e2a\u8fdb\u7a0b\u4e5f\u4f1a\u88ab\u5b83\u9010\u4e2a\u62d6\u4f4f\uff0c\u6700\u7ec8\u7167\u6837\u6ee1\u8f7d\u3002\u6162\u65e5\u5fd7\uff08slowlog\uff09\u7684\u4f5c\u7528\u5c31\u662f\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u66ff\u4f60&#8221;\u6293\u73b0\u884c&#8221;\uff1a\u4efb\u4f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u9608\u503c\u7684\u8bf7\u6c42\uff0c\u5b83\u90fd\u4f1a\u628a\u5f53\u65f6\u7684\u8c03\u7528\u6808\u5b8c\u6574\u8bb0\u4e0b\u6765\uff0c\u4f60\u4e0d\u7528\u5b88\u5728\u5c4f\u5e55\u524d\uff0c\u7b2c\u4e8c\u5929\u7ffb\u65e5\u5fd7\u5c31\u80fd\u770b\u5230\u5361\u987f\u6e90\u5934\u3002<\/p>\n<p>\u914d\u7f6e\u53ea\u9700\u4e24\u884c\uff1a<\/p>\n<pre><code class=\"language-ini\">request_slowlog_timeout = 3s\nslowlog = \/var\/log\/php-fpm\/www-slow.log\n<\/code><\/pre>\n<p><code>request_slowlog_timeout = 3s<\/code> \u8868\u793a\u8d85\u8fc7 3 \u79d2\u7684\u8bf7\u6c42\u4f1a\u88ab\u8bb0\u5f55\u3002\u9608\u503c\u8981\u7ed3\u5408\u4e1a\u52a1\u5b9a\uff1a\u666e\u901a\u5185\u5bb9\u9875\u5e94\u5728 1 \u79d2\u5185\u5b8c\u6210\uff0c\u7ed3\u8d26\u6d41\u7a0b\u53ef\u653e\u5bbd\u5230 5 \u79d2\u3002\u8bbe\u6210 0 \u4f1a\u8bb0\u5f55\u6240\u6709\u8bf7\u6c42\uff0c\u65e5\u5fd7\u91cf\u6781\u5927\uff0c\u53ea\u9002\u5408\u4e34\u65f6\u6392\u67e5\u3002\u6539\u5b8c\u6267\u884c <code>systemctl reload php-fpm<\/code> \u751f\u6548\u3002<\/p>\n<p>\u8dd1\u4e00\u5929\u4e4b\u540e\u6253\u5f00\u65e5\u5fd7\uff0c\u5178\u578b\u7684\u8bb0\u5f55\u957f\u8fd9\u6837\uff1a<\/p>\n<pre><code>[20-Oct-2026 14:32:07]  [pool www] pid 12345\nscript_filename = \/home\/site\/public_html\/index.php\n[0x00007f3a2c1e0f30] query() \/home\/site\/public_html\/wp-includes\/class-wpdb.php:2345\n[0x00007f3a2c1e0e40] get_results() \/home\/site\/public_html\/wp-content\/plugins\/xxx-report\/report.php:88\n<\/code><\/pre>\n<p>\u89e3\u8bfb\u65b9\u6cd5\u662f\u4ece\u4e0a\u5f80\u4e0b\u627e\u7b2c\u4e00\u4e2a\u5c5e\u4e8e <code>wp-content\/plugins\/<\/code> \u6216\u4e1a\u52a1\u4ee3\u7801\u7684\u884c\u3002\u4e0a\u9762\u7684\u4f8b\u5b50\u8bf4\u660e\uff1a\u5361\u987f\u4e0d\u662f\u8d44\u6e90\u4e0d\u8db3\uff0c\u800c\u662f\u67d0\u4e2a\u62a5\u8868\u63d2\u4ef6\u7b2c 88 \u884c\u7684\u6162\u67e5\u8be2\u6bcf\u6b21\u8981\u8dd1 3 \u79d2\u4ee5\u4e0a\uff0c\u9ad8\u5cf0\u671f\u51e0\u4e2a\u7528\u6237\u540c\u65f6\u89e6\u53d1\u5c31\u628a\u8fdb\u7a0b\u6c60\u5360\u6ee1\u3002\u5904\u7406\u65b9\u5f0f\u968f\u4e4b\u660e\u786e\u2014\u2014\u7ed9\u5b57\u6bb5\u8865\u7d22\u5f15\u3001\u52a0\u7f13\u5b58\u6216\u505c\u7528\u63d2\u4ef6\uff0cCPU \u5360\u7528\u901a\u5e38\u5f53\u5929\u5c31\u964d\u4e0b\u6765\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/php-fpm-slowlog-stack.webp\" alt=\"\u6162\u65e5\u5fd7\u5b9a\u4f4d\u5361\u987f\u4ee3\u7801\u793a\u610f\u56fe\" loading=\"lazy\" \/><\/p>\n<h2>\u53c2\u6570\u600e\u4e48\u914d\uff1adynamic \u4e0e static \u7684\u771f\u5b9e\u53d6\u820d<\/h2>\n<p>\u540c\u4e00\u4e2a <code>pm.max_children<\/code> \u6570\u503c\uff0c\u914d\u5728\u4e0d\u540c\u6a21\u5f0f\u4e0b\u8868\u73b0\u5dee\u522b\u5f88\u5927\u3002\u4e0b\u9762\u8fd9\u5f20\u5bf9\u6bd4\u8868\u6765\u81ea\u6211\u4eec\u5904\u7406\u8fc7\u7684\u4e24\u7c7b\u5178\u578b\u5ba2\u6237\u573a\u666f\uff0c\u4f60\u53ef\u4ee5\u5bf9\u7167\u81ea\u5df1\u7684\u4e1a\u52a1\u9009\u578b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5bf9\u6bd4\u7ef4\u5ea6<\/th>\n<th>pm = dynamic<\/th>\n<th>pm = static<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9002\u7528\u6d41\u91cf<\/td>\n<td>\u6ce2\u52a8\u5927\uff0c\u767d\u5929\u9ad8\u5cf0\u3001\u591c\u91cc\u7a7a\u95f2<\/td>\n<td>\u5168\u5929\u5e73\u7a33\uff0c\u8ba2\u5355\u6301\u7eed\u8fdb\u5165<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u4f4e\u5cf0\u671f\u81ea\u52a8\u6536\u7f29\uff0c\u95f2\u7f6e\u5185\u5b58\u5c11<\/td>\n<td>\u59cb\u7ec8\u5360\u6ee1\u56fa\u5b9a\u5185\u5b58<\/td>\n<\/tr>\n<tr>\n<td>\u54cd\u5e94\u5ef6\u8fdf<\/td>\n<td>\u7a81\u53d1\u6d41\u91cf\u6765\u65f6\u9700 fork \u8fdb\u7a0b\uff0c\u9996\u8bf7\u6c42\u7565\u6162<\/td>\n<td>\u65e0 fork \u5f00\u9500\uff0c\u5ef6\u8fdf\u5e73\u7a33<\/td>\n<\/tr>\n<tr>\n<td>\u5178\u578b\u573a\u666f<\/td>\n<td>\u4f01\u4e1a\u5b98\u7f51\u3001\u535a\u5ba2\u3001\u5b63\u8282\u6027\u5916\u8d38\u7ad9<\/td>\n<td>\u7535\u5546\u5e73\u53f0\u3001API \u670d\u52a1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u4e2a\u5b9e\u9645\u6848\u4f8b\u53ef\u4ee5\u8bf4\u660e\u9009\u9519\u6a21\u5f0f\u7684\u4ee3\u4ef7\u3002\u67d0\u5916\u8d38\u72ec\u7acb\u7ad9\u5728<a href=\"https:\/\/cn.hostease.com\/shared-hosting.html\">\u5171\u4eab\u4e3b\u673a<\/a>\u4e0a\u914d\u7f6e\u4e86 <code>pm = dynamic<\/code>\u3001<code>pm.max_children = 5<\/code>\uff0c\u9ed1\u4e94\u4fc3\u9500\u65f6\u5e76\u53d1\u8bf7\u6c42\u4e00\u5ea6\u51b2\u5230 40 \u4e2a\uff0c\u8d85\u51fa\u4e0a\u9650\u7684 35 \u4e2a\u8bf7\u6c42\u5168\u90e8\u6392\u961f\uff0c\u9875\u9762\u54cd\u5e94\u65f6\u95f4\u4ece 800 \u6beb\u79d2\u6da8\u5230 20 \u79d2\u4ee5\u4e0a\uff0c\u5f53\u5c0f\u65f6\u8ba2\u5355\u8f6c\u5316\u7387\u6389\u4e86\u4e00\u534a\u3002\u8fc1\u5230\u5e26\u72ec\u7acb\u8d44\u6e90\u7684\u65b9\u6848\u540e\u6309 2GB \u53ef\u7528\u5185\u5b58\u91cd\u65b0\u8ba1\u7b97\uff0c<code>pm.max_children<\/code> \u63d0\u5230 25\uff0c\u540c\u4e00\u65f6\u6bb5\u7684\u54cd\u5e94\u65f6\u95f4\u7a33\u5b9a\u5728 900 \u6beb\u79d2\u4ee5\u5185\u3002\u8fd9\u4e2a\u6848\u4f8b\u8bf4\u660e\u4e24\u4ef6\u4e8b\uff1a\u4e00\u662f\u53c2\u6570\u5fc5\u987b\u8ddf\u7740\u6d41\u91cf\u8d70\uff0c\u6284\u522b\u4eba\u7684\u914d\u7f6e\u6ca1\u6709\u610f\u4e49\uff1b\u4e8c\u662f\u5f53\u7b97\u51fa\u7684\u8fdb\u7a0b\u6570\u5df2\u7ecf\u6491\u4e0d\u8d77\u4e1a\u52a1\u5cf0\u503c\u65f6\uff0c\u5355\u9760\u8c03\u53c2\u89e3\u51b3\u4e0d\u4e86\uff0c\u9700\u8981\u5347\u7ea7\u5230\u8d44\u6e90\u66f4\u5145\u88d5\u7684<a href=\"https:\/\/cn.hostease.com\/dedicated-server\/\">\u72ec\u7acb\u670d\u52a1\u5668<\/a>\u6216 VPS\uff08<a href=\"https:\/\/cn.hostease.com\/vps\/\">\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668<\/a>\uff09\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u4e2a\u4e2d\u95f4\u8def\u7ebf <code>pm = ondemand<\/code>\uff1a\u5e73\u65f6\u4e0d\u542f\u52a8\u5de5\u4f5c\u8fdb\u7a0b\uff0c\u8bf7\u6c42\u6765\u4e86\u624d fork\uff0c\u5185\u5b58\u6700\u7701\uff0c\u4f46\u9996\u4e2a\u8bf7\u6c42\u8981\u627f\u62c5\u5b8c\u6574\u542f\u52a8\u8017\u65f6\uff0c\u53ea\u9002\u5408\u6d4b\u8bd5\u73af\u5883\uff0c\u751f\u4ea7\u7ad9\u4f1a\u51fa\u73b0&#8221;\u7b2c\u4e00\u4e0b\u7279\u522b\u6162&#8221;\u3002<\/p>\n<h2>\u6539\u5b8c\u4e4b\u540e\uff1a\u7528\u76d1\u63a7\u548c\u72b6\u6001\u9875\u9a8c\u8bc1\u6548\u679c<\/h2>\n<p>\u914d\u7f6e\u6539\u5b8c\u8fd8\u9700\u8981\u4e00\u5957\u9a8c\u8bc1\u95ed\u73af\uff0c\u786e\u8ba4\u8c03\u6574\u751f\u6548\u5e76\u5728\u6d41\u91cf\u589e\u957f\u524d\u63d0\u524d\u9884\u8b66\u3002\u5206\u4e09\u5c42\u6765\u505a\uff1a<\/p>\n<p>\u7b2c\u4e00\u5c42\u662f\u5373\u65f6\u9a8c\u8bc1\u3002\u91cd\u542f\u6216 reload PHP-FPM \u540e\u538b\u6d4b\u4e00\u4e0b\u9996\u9875\uff0c\u89c2\u5bdf\u54cd\u5e94\u65f6\u95f4\u662f\u5426\u56de\u5230\u6b63\u5e38\u533a\u95f4\uff1a<\/p>\n<pre><code class=\"language-bash\">ab -n 200 -c 20 https:\/\/\u4f60\u7684\u57df\u540d\/ | grep -E &quot;Time per request|Failed requests&quot;\n<\/code><\/pre>\n<p>\u538b\u6d4b\u7ed3\u679c\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u5bf9\u7167\u6211\u4eec\u4e4b\u524d\u6574\u7406\u7684 <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/ttfb-hosting-optimization\/\">TTFB \u4e0e\u4e3b\u673a\u4f18\u5316\u65b9\u6cd5<\/a> \u68c0\u67e5\u9996\u5b57\u8282\u65f6\u95f4\u662f\u5426\u56de\u5230\u6b63\u5e38\u533a\u95f4\uff0c\u90a3\u7bc7\u6587\u7ae0\u91cc\u7684\u4f18\u5316\u624b\u6bb5\u548c\u672c\u6587\u7684\u8fdb\u7a0b\u6c60\u8c03\u4f18\u53ef\u4ee5\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<p>\u7b2c\u4e8c\u5c42\u662f\u5f00\u542f\u72b6\u6001\u9875\u6301\u7eed\u89c2\u5bdf\u3002\u5728\u8fdb\u7a0b\u6c60\u914d\u7f6e\u4e2d\u52a0\u5165 <code>pm.status_path = \/fpm-status<\/code>\uff0c\u914d\u5408 Nginx \u7684 location \u653e\u884c\uff0c\u5c31\u80fd\u5b9e\u65f6\u770b\u5230 <code>active processes<\/code>\uff08\u6d3b\u8dc3\u8fdb\u7a0b\u6570\uff09\u3001<code>listen queue<\/code>\uff08\u6392\u961f\u6570\uff09\u548c <code>max children reached<\/code>\uff08\u662f\u5426\u89e6\u9876\uff09\u4e09\u4e2a\u5173\u952e\u6307\u6807\u3002\u5224\u65ad\u6807\u51c6\uff1a<code>listen queue<\/code> \u5e94\u957f\u671f\u4e3a 0\uff0c<code>max children reached<\/code> \u51fa\u73b0\u975e\u96f6\u503c\u5c31\u8bf4\u660e\u4e0a\u9650\u8fd8\u9700\u8981\u4e0a\u8c03\u6216\u5b58\u5728\u6162\u8bf7\u6c42\u3002<\/p>\n<p>\u7b2c\u4e09\u5c42\u662f\u7559\u4e0b\u8bc1\u636e\u94fe\u3002\u628a\u6162\u65e5\u5fd7\u63a5\u5165 logrotate \u9632\u6b62\u5355\u6587\u4ef6\u81a8\u80c0\uff0c\u6bcf\u5468\u5bfc\u51fa\u4e00\u6b21\u72b6\u6001\u9875\u5feb\u7167\u5bf9\u6bd4\u8fdb\u7a0b\u6570\u8d8b\u52bf\uff1a\u6d3b\u8dc3\u8fdb\u7a0b\u6570\u8fde\u7eed\u4e24\u5468\u722c\u5347\u800c\u6d41\u91cf\u6ca1\u53d8\uff0c\u5927\u6982\u7387\u662f\u65b0\u63d2\u4ef6\u5728\u6cc4\u6f0f\u5185\u5b58\u3002\u670d\u52a1\u5668\u5c42\u9762\u7684\u5176\u4ed6\u8c03\u4f18\u9879\uff0c\u53ef\u4ee5\u53c2\u8003 <a href=\"https:\/\/cn.hostease.com\/blog\/server\/\">\u670d\u52a1\u5668\u4f18\u5316\u5206\u7c7b<\/a> \u4e0b\u7684\u7cfb\u5217\u6587\u7ae0\u3002<\/p>\n<p>\u5f53\u8fd9\u5957\u95ed\u73af\u8dd1\u8d77\u6765\u4e4b\u540e\uff0c\u7edd\u5927\u591a\u6570&#8221;\u7a81\u7136\u5361\u6b7b&#8221;\u7684\u4e8b\u6545\u90fd\u4f1a\u53d8\u6210&#8221;\u63d0\u524d\u4e00\u5468\u770b\u5230\u7684\u66f2\u7ebf&#8221;\u3002\u5982\u679c\u4f60\u7684\u7ad9\u70b9\u76ee\u524d\u8fd8\u5728\u5171\u4eab\u73af\u5883\u91cc\u3001\u8fde SSH \u6743\u9650\u548c\u6162\u65e5\u5fd7\u90fd\u6ca1\u6cd5\u914d\u7f6e\uff0c\u5efa\u8bae\u8003\u8651\u8fc1\u79fb\u5230\u8d44\u6e90\u72ec\u4eab\u7684\u65b9\u6848\u2014\u2014Hostease \u7684 <a href=\"https:\/\/cn.hostease.com\/vps\/\">VPS \u4e3b\u673a<\/a> \u548c <a href=\"https:\/\/cn.hostease.com\/dedicated-server\/\">\u72ec\u7acb\u670d\u52a1\u5668<\/a> \u90fd\u63d0\u4f9b\u5b8c\u6574\u7684 PHP-FPM \u914d\u7f6e\u6743\u9650\u548c\u4e2d\u6587\u6280\u672f\u652f\u6301\uff0c\u53ef\u4ee5\u6309\u4e0a\u6587\u516c\u5f0f\u81ea\u884c\u8c03\u4f18\uff0c\u4e5f\u53ef\u4ee5\u8ba9\u652f\u6301\u56e2\u961f\u534f\u52a9\u6838\u67e5\u914d\u7f6e\u3002<\/p>\n<h2>\u603b\u7ed3\u4e0e\u884c\u52a8\u5efa\u8bae<\/h2>\n<p>\u56de\u987e\u6574\u6761\u6392\u67e5\u8def\u7ebf\uff1a\u5148\u7528 <code>ps<\/code> \u548c PHP-FPM \u65e5\u5fd7\u786e\u8ba4\u8fdb\u7a0b\u6c60\u662f\u5426\u89e6\u9876\uff0c\u518d\u7528&#8221;\u53ef\u5206\u914d\u5185\u5b58 \u00f7 \u5355\u8fdb\u7a0b\u5e73\u5747\u5185\u5b58&#8221;\u7b97\u51fa\u5408\u7406\u7684 <code>pm.max_children<\/code>\uff0c\u7136\u540e\u6253\u5f00\u6162\u65e5\u5fd7\u628a\u62d6\u6162\u8bf7\u6c42\u7684\u5177\u4f53\u4ee3\u7801\u884c\u63ea\u51fa\u6765\uff0c\u6700\u540e\u901a\u8fc7\u72b6\u6001\u9875\u6301\u7eed\u9a8c\u8bc1\u3002\u8fd9\u56db\u6b65\u8d70\u5b8c\uff0c\u5361\u987f\u6e90\u5934\u57fa\u672c\u90fd\u80fd\u5b9a\u4f4d\u5230\u63d2\u4ef6\u7ea7\u522b\u3002<\/p>\n<p>\u7ed9\u6b63\u5728\u5904\u7406\u540c\u7c7b\u95ee\u9898\u7684\u4f60\u4e09\u6761\u5efa\u8bae\uff1a\u7b2c\u4e00\uff0c\u4eca\u5929\u5c31\u68c0\u67e5\u4e00\u904d PHP-FPM \u65e5\u5fd7\u91cc\u6709\u6ca1\u6709 <code>reached pm.max_children<\/code> \u8b66\u544a\uff0c\u5b83\u51fa\u73b0\u8fc7\u7684\u6b21\u6570\u5c31\u662f\u4f60\u6b63\u5728\u6d41\u5931\u7684\u8bf7\u6c42\u91cf\uff1b\u7b2c\u4e8c\uff0c\u628a\u6162\u65e5\u5fd7\u9608\u503c\u8bbe\u5728 3 \u79d2\u5e76\u4fdd\u7559\u4e00\u5468\u65e5\u5fd7\uff0c\u7528\u771f\u5b9e\u8c03\u7528\u6808\u4ee3\u66ff\u731c\u6d4b\uff1b\u7b2c\u4e09\uff0c\u5982\u679c\u4f60\u9700\u8981\u6258\u7ba1\u73af\u5883\u4e0b\u5f00\u7bb1\u5373\u7528\u7684 PHP \u8c03\u4f18\u652f\u6301\uff0c\u53ef\u4ee5\u8003\u8651 <a href=\"https:\/\/cn.hostease.com\/shared-hosting.html\">Hostease \u5171\u4eab\u4e3b\u673a<\/a>\uff0c\u9884\u7f6e\u7684 PHP \u8fd0\u884c\u73af\u5883\u4e0e\u8fdb\u7a0b\u6c60\u914d\u7f6e\u80fd\u8986\u76d6\u5927\u591a\u6570\u4e2d\u5c0f\u7ad9\u70b9\uff0c\u9047\u5230\u95ee\u9898\u4e5f\u6709\u4e2d\u6587\u5de5\u5355\u968f\u65f6\u54cd\u5e94\u3002<a href=\"https:\/\/cn.hostease.com\/blog\/server\/\">\u670d\u52a1\u5668\u6027\u80fd<\/a>\u95ee\u9898\u4ece\u6765\u4e0d\u662f\u4e00\u6b21\u6027\u4fee\u597d\u7684\uff0c\u4f46\u53ea\u8981\u76d1\u63a7\u5728\u3001\u65e5\u5fd7\u5728\uff0c\u6bcf\u6b21\u5361\u987f\u90fd\u4f1a\u53d8\u6210\u4e0b\u4e00\u6b21\u4f18\u5316\u7684\u8f93\u5165\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f51\u7ad9\u7a81\u7136\u5361\u987f\u3001CPU \u88ab\u5360\u6ee1\u5374\u627e\u4e0d\u5230\u539f\u56e0\uff1f\u672c\u6587\u901a\u8fc7 pm.max_children \u53c2\u6570\u8ba1\u7b97\u3001PHP-FPM \u6162\u65e5\u5fd7\u914d\u7f6e\u548c\u771f\u5b9e\u8c03\u53c2\u6848\u4f8b\uff0c\u6559\u4f60\u4e00\u6b65\u6b65\u5b9a\u4f4d\u5361\u987f\u6e90\u5934\uff0c\u5e76\u7ed9\u51fa\u53ef\u76f4\u63a5\u590d\u5236\u7684\u914d\u7f6e\u793a\u4f8b\u4e0e\u76d1\u63a7\u9a8c\u8bc1\u65b9\u6cd5\u3002<\/p>\n","protected":false},"author":2,"featured_media":33948,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3822],"tags":[3309,4496,5360,4818,5361],"class_list":["post-33951","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","tag-cpu","tag-php-fpm-2","tag-pmmaxchildren","tag-4818","tag-5361"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/php-fpm-cpu-pm-max-children-cover.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/33951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/comments?post=33951"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/33951\/revisions"}],"predecessor-version":[{"id":34156,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/33951\/revisions\/34156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media\/33948"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media?parent=33951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/categories?post=33951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/tags?post=33951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}