php / php/php-src

PHP-FPM Process Count Inconsistencies

オープン
#18,956 コメント 3 件 リアクション 1 件 担当者 1 名 GitHub で見る

@bukka がすでに取り組んでいます。

2025年7月1日 から。

Bug SAPI: fpm Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

Summary

PHP-FPM continues to report inaccurate process counts in 2025, with active processes showing as extremely low even under high load. This appears to be a continuation or regression of bug #76003, which was supposedly fixed in April 2022.

Description

The PHP-FPM status endpoint reports inconsistent and incorrect process counts, specifically:

  • "active processes" showing as very low (often 1-3) during periods of high traffic
  • Manual process state counting reveals many processes in "Running" and other active states
  • Discrepancy between calculated active processes and FPM's reported active count

Steps to Reproduce

  1. Set up PHP-FPM with moderate traffic (50+ concurrent requests)
  2. Query FPM status endpoint: http://localhost/fmp-status?json&full
  3. Compare active processes field with manual state counting
  4. Observe discrepancy between reported and actual active processes

Expected Result

  • active processes should equal the sum of all non-idle process states
  • Count should reflect actual load and match manual calculations

Actual Result

  • active processes shows artificially low numbers (1-5) during high load
  • Manual state counting shows 20-40+ processes in active states
  • Creates monitoring confusion and incorrect capacity planning

Debug session

Video which displays the counts from process list and from the php-fpm summaries.
FPM reported is the raw active processes, idle processes and total processes
The other values are calculated based in the proccess list states.
https://vimeo.com/1096855168?share=copy

Simple Test Script

<?php
// Enhanced monitoring script that reveals the discrepancy
$fmpStatus = file_get_contents('http://localhost:8080/fmp-status?json&full');
$fmp = json_decode($fmpStatus, true);

$stateCounts = ['Idle' => 0, 'Running' => 0, 'Reading headers' => 0, /* etc */];
foreach ($fmp['processes'] as $process) {
    $stateCounts[$process['state']]++;
}

$calculatedActive = count($fmp['processes']) - $stateCounts['Idle'];
$reportedActive = $fmp['active processes'];

echo "Calculated active: {$calculatedActive}\n";
echo "FPM reported active: {$reportedActive}\n";
echo "Discrepancy: " . ($calculatedActive - $reportedActive) . "\n";
?>

Related Issues

Original bug #76003 (supposedly fixed in April 2022)
GitHub issue #14212: "FPM Status: active processes greater than pm.max_children"

PHP Version
PHP 8.4.1 (fpm-fcgi) (built: Nov 21 2024 18:03:22) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.1, Copyright (c), by Zend Technologies
Operating System

Debian GNU/Linux 12 (bookworm)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。