fpm: calculate accurate process counts from states during status generation #18960
+21
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix PHP-FPM process count discrepancy in status endpoint
Problem
The PHP-FPM status endpoint reports inaccurate
active processes
andidle processes
counts that don't match the actual process states. This causes significant issues for:Example Discrepancy
Replace unreliable scoreboard counters with counts calculated from actual process states. Since status endpoint already locks and reads all processes, this adds zero performance overhead while ensuring 100% accurate metrics.
Resolves monitoring discrepancies where active processes were incorrectly reported as significantly lower than actual non-idle processes under load.
Root Cause Analysis
The issue stems from race conditions in scoreboard counter updates, not the process states themselves:
fpm_scoreboard_update()
from multiple locationsInvestigation of
fpm_scoreboard.c
shows that scoreboard counters are not calculated from process states but rather maintained as separate values that can drift due to concurrent updates.Solution
Calculate
active processes
andidle processes
directly from actual process states during status generation, instead of relying on potentially inconsistent scoreboard counters.Implementation Details
The fix leverages the existing process acquisition loop in
fpm_status_export_to_zval()
:Fixes #18956