Skip to main content

Queue Management

Allegro uses Laravel Horizon to supervise background job queues. Horizon manages worker processes, tracks throughput and failure rates, and provides a real-time dashboard.

Queues

Allegro defines three queues, processed in strict priority order by the Horizon supervisor.

QueuePriorityPurpose
high1 (highest)Latency-sensitive jobs: magic link emails and member profile pre-warming
default2General background jobs (webhooks, etc.)
audience-sync3 (lowest)Audience sync provider jobs, dispatched every 5 minutes by the scheduler

The supervisor uses balance: false with queues listed in priority order. Horizon drains high before picking up default jobs, and default before audience-sync. Note that priority applies to selecting the next job — an in-flight lower-priority job runs to completion before the worker picks up a higher-priority queued job.

Requirements

Horizon requires Redis. Set QUEUE_CONNECTION=redis in your .env.

VariableRequiredDescription
QUEUE_CONNECTIONYesMust be redis
REDIS_HOSTYesRedis host
REDIS_PORTYesRedis port (default: 6379)
HORIZON_PREFIXNoRedis key prefix (default: horizon:)
Queue connection

If QUEUE_CONNECTION is not redis, Horizon starts but no workers are spawned and jobs accumulate unprocessed.

Starting Horizon

In development:

composer run dev

Horizon starts automatically alongside the web server, Pail, and Vite.

To run Horizon in isolation:

php artisan horizon

Dashboard

The Horizon dashboard is at /horizon. It shows live queue metrics, recent and failed jobs, worker status, and throughput graphs.

Dashboard access

The dashboard is restricted to super admins (Alley staff with verified @alley.com accounts) via the viewHorizon gate registered in AllegroServiceProvider. In local environments Horizon's default behavior also permits access without authentication.

Metrics Snapshots

horizon:snapshot runs every five minutes via the Laravel scheduler. It records queue throughput and wait time metrics used to populate the dashboard graphs. The command must run continuously for the graphs to populate.

Supervisor Configuration

The supervisor config lives in packages/allegro-platform/config/horizon.php. The defaults apply to all environments; environment-specific overrides are in environments.production and environments.local.

KeyDefaultDescription
balancefalseStrict queue-order priority (not auto-balanced)
queue['high', 'default', 'audience-sync']Queue processing order, highest priority first
maxProcesses1 (local) / 5 (staging) / 5 (production)Maximum worker processes
tries1Job attempts before marking as failed
timeout60Seconds before a job is considered timed out

To publish the config for local customization:

php artisan vendor:publish --tag=horizon-config