Repository navigation
fix(php-fpm): let autotune size the spare servers, clamp manual sizing - #57
Merged
Merged
Conversation
A container whose memory limit autotuned php-fpm below 6 workers
crash-looped: "pm.min_spare_servers(1) and pm.max_spare_servers(6)
cannot be greater than pm.max_children(4)", exit 78. cbox-init's boot
autotune exports valid values for all four, but it runs after the
entrypoint, which wrote the pre-tune spare defaults into zz-pm-mode.conf
as literals - so only max_children (still a placeholder in the pool
file) took the tuned value.
The dynamic drop-in is written with ${PHP_FPM_*} placeholders again, the
same as the baked one. Manual sizing (PHP_FPM_MAX_CHILDREN, which turns
autotune off) clamps the spare counts to fit max_children and warns.
test-memory-limits.sh runs the image under -m 256m and -m 512m and with
PHP_FPM_MAX_CHILDREN=2, probing /fpm-ping (/healthz never reaches FPM).
It runs in the e2e smoke test and before every php-fpm-nginx tier is
promoted. 3 failures on the published 8.4 image, 0 after.
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
LGTM
Talking to Cbox
- Reply under a finding to ask Cbox about it.
/cbox fixin reply to a finding: Cbox fixes it on this pull request's branch, or, when it can't push there, on a new branch whose push waits for a confirm in Cbox./cbox reviewreviews this pull request again now./cbox <question>asks Cbox about this pull request./cbox helpshows this list.
Only people who can push to this repository and have linked their GitHub account in Cbox can use /cbox.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TLDR: php-fpm crash-looped in any container where autotune picked fewer than 6 workers (e.g. a 512Mi pod). Fixed in the entrypoint library. cboxdk/init needs no change.
What broke. On cbox-hel1, a 512Mi pod (Reverb on
php-fpm-nginx:8.4-bookworm) failed with:pm.min_spare_servers(1) and pm.max_spare_servers(6) cannot be greater than pm.max_children(4), exit 78.docker run -m 256mor-m 512mreproduces it on the published images.Why. cbox-init's boot autotune does its job: at 512m it exports
max_children=4with spare counts2/1/2. But it runs after the entrypoint, which had already written the defaults (2/1/6) intozz-pm-mode.confas literal numbers.pm.max_childrenis still a${…}placeholder in the pool file, so it picked up the tuned value. The spare counts didn't. This came in with 571b696.Fix
${PHP_FPM_*}placeholders again, the same as the bakedpm-mode-dynamic.conf. FPM now reads all four tuned values.PHP_FPM_MAX_CHILDRENturns autotune off and used to leavemax_spareat 6. The entrypoint now clamps the spare counts so1 ≤ min ≤ start ≤ max_spare ≤ max_children, and logs aWARNwith the values it used.Why CI missed it. None of the smoke tests set a memory limit, so the medium profile always picked more than 6 workers. They also probe
/healthz, which nginx answers without asking php-fpm. Newtests/e2e/scenarios/test-memory-limits.shruns-m 256m,-m 512m, and-m 256mwithPHP_FPM_MAX_CHILDREN=2. It probes/fpm-pingand fails if FPM ever rejected its config. It runs in the e2e smoke test and in the pre-promotion smoke test of all 8 php-fpm-nginx tiers. The merge job's sparse checkout now includes the script.Verified locally (arm64, 8.4)
max_children=4, FPM started 2 workers.PHP_FPM_MAX_CHILDREN=2: clamps to2/1/2and starts. Tested with the new lib mounted, because that image takes its lib from php-base.Not covered: the legacy
PHP_FPM_PM_MAX_CHILDRENoverride (php-fpm-nginx'szz-env-overrides.conf) is still written as a literal and does not turn autotune off. That path was already broken before this PR and this change leaves it as it was.Merging publishes new image tags: php-base rebuilds on
common/**and triggers php-fpm, which triggers php-fpm-nginx.