perf(horizon): skip queues for platforms that are disabled - #321
Open
maciejdzierzek wants to merge 1 commit into
Open
perf(horizon): skip queues for platforms that are disabled#321maciejdzierzek wants to merge 1 commit into
maciejdzierzek wants to merge 1 commit into
Conversation
The social-publishing supervisor listens on Platform::allQueues(), which maps
over every enum case regardless of the per-platform *_ENABLED toggles. With
minProcesses => 1 that means one worker per supported platform - even on an
installation that only ever connects two or three of them.
On a single-workspace self-host that was 19 Horizon workers at roughly 75 MB
each; filtering by the toggles brought it to 9 and cut container memory from
1.66 GB to 1.06 GB, with no change in publishing behaviour.
Note on the implementation: the filter reads env() directly rather than calling
Platform::isEnabled(). Config files load alphabetically, so config('trypost.*')
does not exist yet while horizon.php is evaluated - isEnabled() would silently
return its default of true and the filter would be a no-op. This bites at
config:cache time, so it is invisible in tinker.
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.
The
social-publishingsupervisor listens onPlatform::allQueues(), which maps over every enum case regardless of the per-platform*_ENABLEDtoggles that already exist inconfig/trypost.php. Combined withminProcesses => 1, that gives one worker per supported platform — including the ones an installation never connects.On a single-workspace self-host publishing to three networks, that was 19 Horizon workers at roughly 75 MB each. After filtering by the toggles: 9 workers, container memory 1.66 GB → 1.06 GB, with no change in publishing behaviour. On a memory-billed host that is real money for idle workers.
One subtlety worth flagging in review
The filter reads
env()directly instead of calling the existingPlatform::isEnabled(). That is deliberate, and I got it wrong the first time:isEnabled()readsconfig(trypost.platforms.*.enabled), but config files load alphabetically —horizon.phpis evaluated beforetrypost.phpexists in the repository. SoisEnabled()falls back to its default oftrueand the filter silently becomes a no-op.It is an easy one to miss, because it only manifests at
config:cachetime. CallingPlatform::allQueues()in tinker afterwards returns the correctly filtered list while the cached config still holds all 14 queues — which is exactly the confusing state I debugged through.If you would rather keep the logic on the enum, it would need its own env-reading path rather than going through
config().Behaviour
*_ENABLEDset stays enabled (env(..., true)).Running in production since 2026-08-31.