PHP Queue Workers
debt(d8/e6/b6/t7)
Closest to 'silent in production until users hit it' (d9), -1 because Laravel Horizon dashboard and supervisor status can surface dead workers if monitored. Per detection_hints.automated=no, there's no automated check — crashed workers, memory leaks, and missing dead-letter queues silently accumulate until the queue backs up visibly.
Closest to 'cross-cutting refactor across the codebase' (e7), -1 because quick_fix involves configuring Supervisor/Horizon, adding timeouts, max-tries, and a dead-letter queue — this is more than a single file but stays within the deployment/worker configuration layer rather than touching all business code.
Closest to 'strong gravitational pull' (b7), -1 because applies_to is the queue-worker context specifically. Once jobs are async, every long-running task gets shaped around job design, retries, idempotency, and worker lifecycle, but it doesn't redefine the whole system.
Closest to 'serious trap (contradicts how a similar concept works elsewhere)' (t7), grounded in the misconception that workers restart automatically on crash — developers assume PHP-FPM-like supervision but `queue:work` is just a process that dies silently, contradicting expectations from web request handling.
Also Known As
TL;DR
Explanation
PHP queue workers process jobs from queues (Redis, SQS, database) in persistent background processes. Laravel Horizon: dashboard with real-time metrics, auto-scaling worker pools, per-queue configuration, memory limit enforcement. Supervisor: process control system that monitors and restarts crashed workers, manages multiple worker processes with log rotation. Job patterns: $tries and $backoff for retry logic, failed() hook for cleanup on permanent failure, ShouldBeUnique for deduplication.
Common Misconception
Why It Matters
Common Mistakes
- Workers started manually without Supervisor — crashed workers never restart
- No memory limit — PHP workers accumulate memory leaks over time without restart
- No job timeout — a hanging job blocks that worker indefinitely
- Single worker handling all job types — slow report generation blocks fast email sending
Code Examples
# Manual worker without process management:
php artisan queue:work &
# Worker crashes: nobody notices
# Queue backs up silently
# Server restarts: worker never comes back
# 2 hours later: customer reports emails not sending
# /etc/supervisor/conf.d/horizon.conf:
[program:horizon]
process_name=%(program_name)s
command=php /var/www/app/artisan horizon
autostart=true
autorestart=true
user=www-data
stopwaitsecs=3600
stdout_logfile=/var/log/supervisor/horizon.log
# config/horizon.php — separate queues, memory limits:
# 'supervisor-1' => ['queue'=>['critical','default','low'],'processes'=>10,'memory'=>128]