From 8be20c1c57a44bd7bb7238e1d127a34da743e5fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Dzier=C5=BCek?= Date: Mon, 31 Aug 2026 21:29:59 +0200 Subject: [PATCH] perf(horizon): skip queues for platforms that are disabled 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. --- config/horizon.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/config/horizon.php b/config/horizon.php index c2e8b3184..a1a726319 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -228,7 +228,19 @@ 'social-publishing' => [ 'connection' => 'redis', - 'queue' => Platform::allQueues(), + // Only queue platforms that are actually enabled. Reading the toggles from + // env() rather than config() is deliberate: config files are loaded in + // alphabetical order, so config('trypost.*') is not populated yet while this + // file is being evaluated - Platform::isEnabled() would always fall back to + // true here. Without this filter every supported platform gets a worker + // (minProcesses => 1), including ones the installation never connects. + 'queue' => array_values(array_filter( + Platform::allQueues(), + fn (string $queue) => filter_var( + env(Str::upper(Str::replace('-', '_', Str::after($queue, 'social-'))).'_ENABLED', true), + FILTER_VALIDATE_BOOLEAN + ) + )), 'balance' => 'auto', 'autoScalingStrategy' => 'time', 'minProcesses' => 1,