← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

PHP Queue Workers

messaging PHP 7.0+ Intermediate

Also Known As

Laravel Horizon Supervisor queue worker background jobs php artisan queue:work

TL;DR

Laravel Horizon for Redis queues with dashboard and auto-scaling; Supervisor for process management ensuring crashed workers automatically restart.

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

Queue workers restart automatically when they crash — without Supervisor or systemd, a crashed worker process simply stops; the queue silently backs up until someone notices and restarts manually.

Why It Matters

Processing 1000 emails synchronously in a web request blocks users for minutes — queue workers process them asynchronously in the background, and Supervisor automatically restarts any worker that crashes.

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

✗ Vulnerable
# 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
✓ Fixed
# /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]

Added 16 Mar 2026
Edited 22 Mar 2026
Views 28
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 2 pings W 2 pings T 2 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 1 ping T 1 ping F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S
No pings yet today
Amazonbot 7 Perplexity 6 Google 4 Ahrefs 2 Unknown AI 2 SEMrush 2 ChatGPT 2
crawler 21 crawler_json 4
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Configure Laravel Horizon or Symfony Messenger workers with supervisor/systemd — set max-tries=3 and a timeout, and always have a dead-letter queue for failed jobs
📦 Applies To
PHP 7.0+ queue-worker laravel symfony
🔗 Prerequisites
🔍 Detection Hints
Queue workers started manually not via supervisor; no dead-letter queue; workers with no timeout; memory leaks accumulating over days
Auto-detectable: ✗ No supervisor laravel-horizon symfony-messenger
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant