Laravel Queue & Job System: From Table Creation to Production Deployment
July 1, 2025🚀 Laravel Queue & Job System
We’re gonna walk you through Laravel queues from setup to deploying in production using Supervisor.
Step 1: Create queue tables
Run these commands:
php artisan queue:table
php artisan queue:failed-table
php artisan queue:batches-table
php artisan migrate
Step 2: Monitor failed jobs
Run:
php artisan queue:failed
You’ll get a list with ID, connection, exception, and timestamp.
Step 3: Retry failed jobs
php artisan queue:retry 5 # retry single job
php artisan queue:retry all # retry all failed jobs
Step 4: Delete failed jobs
php artisan queue:flush
Step 5: Prune old failed jobs
php artisan queue:prune-failed # older than 24h
php artisan queue:prune --hours=48 # older than 48h
Step 6: Retry logic with backoff
Examples:
php artisan queue:work --tries=2
php artisan queue:work --queue=notification --tries=2 --backoff=1200
php artisan queue:work --queue=notification --tries=2 --backoff=10,20
Step 7: Job batches
Use batches to group jobs (e.g., sending 10,000 emails) and track overall progress, retries, and notifications.
Step 8: Production deployment with Supervisor
Supervisor restarts your queue workers on failure. Example config:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --tries=3 --backoff=30 --timeout=120 --max-jobs=1000 --max-time=3600 --sleep=3 --reset=1
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
Save to /etc/supervisor/conf.d/laravel-worker.conf
, then:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
Blog
Task Reminder with Laravel & MongoDB
Jun 30, 2025
📌 Building a Task Reminder App This guide shows how to set up a Laravel app using MongoDB to implement a task reminder system with authentication,...
Guide to Scroll‑Driven Animations with CSS
Jun 26, 2025
Guide to Scroll‑Driven Animations with CSS CSS animations can now be linked to user scrolling without any JavaScript — just pure CSS. 1. Thr...
Supercharge Your PHP Enums with archtechx/enums
Jul 01, 2025
Supercharge Your PHP Enums with archtechx/enums PHP 8.1 introduced native enums—type‑safe sets of named values like statuses or roles. The arch...
Stop Copy-Pasting Code! Learn How to Use Traits in Laravel the Right Way
Jul 01, 2025
🚫 Stop Copy-Pasting Code! Ever duplicated slug logic or logging across multiple models? Laravel's Traits got your back. 1. What’s a Trait?...
Analyze Laravel Projects with Introspect
Jul 01, 2025
Analyze Laravel Codebases with Laravel Introspect If you’re doing a complex refactor or building dev tools, Laravel Introspect helps you quer...
Laravel 12.16.0 - New Features for Developers
Jun 03, 2025
Laravel 12.16.0 - New Features for Developers 1. New Validation Rule: in_array_keys You can now validate that an array contains at least one of the...
