Repository navigation
Make the PHP-FPM process manager configurable - #133
Merged
peterjaap merged 1 commit intoAug 7, 2026
Merged
Conversation
Collaborator
|
@Aquive looks like Github Actions had an internal error. Could you re--trigger the tests? |
Pool configs hardcoded `pm = dynamic` with `pm.max_children = 50`, sized
as if each pool had the machine to itself. On a host running several
projects those defaults collectively oversubscribe it: PHP-FPM starts
workers well past the core count and each active Magento worker can hold
hundreds of megabytes, so a single page load can push the machine into
swap. There was no way to tune this — the values were literals in
pool.go and isolated.go, and a hand-edited pool file is overwritten on
the next `magebox start`.
Add a `pm` block to `.magebox.yaml` / `.magebox.local.yaml` and a
`default_pm` baseline to `~/.magebox/config.yaml`:
pm:
mode: ondemand # static | dynamic | ondemand
max_children: 12
process_idle_timeout: 30s
Precedence is project > global > built-in, merged key by key so a local
override can tune a single value. `ondemand` is the notable addition for
multi-project machines: dormant projects start no workers at all.
Only the directives valid for the selected mode are written — `ondemand`
emits `pm.process_idle_timeout` instead of the spare-server keys, and
`static` emits neither.
Values are validated before the pool file is written, mirroring the
constraints PHP-FPM enforces at startup. This matters because a single
malformed pool prevents the FPM master from starting, taking down every
project on that PHP version. Lowering only `max_children` scales the
untouched spare-server defaults down to fit rather than erroring, so the
common case needs one key instead of four.
Defaults are unchanged, so existing installs render byte-identical pool
files. Isolated masters store their resolved settings in the registry so
StartAllIsolated regenerates configs identically without re-reading
project config; entries written by older versions fall back to the
built-in defaults.
Also corrects the pm values in the PHP-FPM service docs, which still
showed 5/2/10/500 rather than the 8/4/12/1000 the code has been
generating.
Aquive
force-pushed
the
feat/configurable-fpm-process-manager
branch
from
August 7, 2026 10:09
5f0fffe to
a3bcf9b
Compare
Contributor
Author
|
@peterjaap done. I couldn't do it by web because of permissions. I did a push to retrigger it. The current failing job is a permission issue it seems? (Claude: The Comment PR with artifact links job fails on fork PRs because GitHub restricts the workflow's GITHUB_TOKEN to read-only for pull requests from forks). |
Collaborator
|
@Aquive yeah that one fails sometimes, it's weird. Looks like everything's green, merging it! Thanks! |
peterjaap
pushed a commit
that referenced
this pull request
Aug 7, 2026
The comment-artifacts job requests pull-requests: write, but GitHub caps GITHUB_TOKEN to read-only for pull_request runs originating from a fork. Posting the comment therefore fails with 403 'Resource not accessible by integration', marking the whole run as failed even when every build, test and lint job passed. This has broken every fork PR since 1fe4817 added the job (#128, #133, and external contributions such as #123). PRs from branches in this repository are unaffected and keep their artifact comment. Gate the job on the PR originating from this repository instead of merely being a pull_request. On push events github.event.pull_request is null, so the job is still skipped there, matching the previous guard.
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.
Problem
Pool configs hardcode
pm = dynamicwithpm.max_children = 50, sized as if each pool had the machine to itself. With several projects started, the defaults oversubscribe the host — on my 10-core setup, 8 pools meant 400 potential workers, and one Magento page load in developer mode spiked a pool to 46 active workers and the load average to 78.There is no way to tune it: the values are literals in
pool.go/isolated.go, and a hand-edited pool file is overwritten on the nextmagebox start.Solution
A
pmblock in.magebox.yaml/.magebox.local.yaml, plus adefault_pmbaseline in~/.magebox/config.yaml:Precedence is project > global > built-in, merged key by key.
ondemandis the useful addition for multi-project machines: dormant projects start no workers at all.Keys:
mode,max_children,max_requests(all modes),start_servers,min_spare_servers,max_spare_servers(dynamic),process_idle_timeout(ondemand). Only the directives valid for the selected mode are rendered.Validation
Values are checked before the pool file is written, mirroring PHP-FPM's own startup constraints — one malformed pool stops the FPM master, taking down every project on that PHP version. Lowering only
max_childrenscales the untouched spare-server defaults down to fit rather than erroring; explicitly-set values are never rewritten.Compatibility
Defaults unchanged — without a
pmblock, pool files render byte-identical. The new argument onGenerate/GenerateWithResult/Enableis nullable. Isolated masters persist resolved settings in the registry; older entries fall back to defaults.Also corrects
vitepress/services/php-fpm.md, which documented5/2/10/500while the code generates8/4/12/1000.CHANGELOG.mduntouched, as it appears to be maintained in release commits.Testing
New tests for precedence, merging, the scaling rule, each validation constraint, and pool rendering per mode (including that
nilstill yields the historical defaults).go test ./...,go vet ./...andgolangci-lint run ./...clean.