Queue Concepts and Drivers
Understand async processing and configure database or Redis queue drivers.
Queue Concepts and Drivers is a free PHP Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the PHP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Are Queues?
Queues let you defer slow or resource-intensive tasks (sending emails, resizing images, hitting external APIs) to background workers, keeping your HTTP responses fast.
Queue Architecture
The main process (web server) pushes jobs onto a queue. Separate worker processes pull and execute jobs asynchronously.
Available Queue Drivers
Laravel supports multiple queue backends:
database— jobs stored in the DB (good for getting started)redis— fast, production-readysqs— AWS Simple Queue Servicebeanstalkd— fast, lightweightsync— runs immediately (local development)
Configuring the Queue Driver
Set the driver in .env.
# .env
QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379The database Driver Setup
If using the database driver, create the jobs table.
$ php artisan queue:table
$ php artisan migrateStarting a Queue Worker
The worker process pulls and executes jobs from the queue.
$ php artisan queue:work
# Or specify connection and queue:
$ php artisan queue:work redis --queue=emails,defaultqueue:listen vs queue:work
queue:work loads the app once and processes jobs in memory — faster but requires worker restart after code changes. queue:listen reloads the app for each job — easier for development.
Failed Jobs
When a job fails after all retries, it is stored in the failed_jobs table. View and retry with Artisan.
$ php artisan queue:failed
$ php artisan queue:retry all
$ php artisan queue:flushQueue Priorities
Define multiple named queues and assign priorities when starting the worker.
$ php artisan queue:work --queue=high,default,low
# Worker checks high first, then default, then lowHorizon Dashboard
For Redis queues, Laravel Horizon provides a beautiful real-time dashboard showing throughput, failed jobs, and worker stats.
Choosing a Driver
Use sync locally, database for small projects, redis for production scale. Avoid SQS unless you are already in AWS and need infinite scale.
Summary
Queues offload slow work to background workers. Configure the driver in .env, create jobs with Artisan, start workers with queue:work. Monitor failed jobs in the failed_jobs table.
Quick Check
Which queue driver runs jobs immediately in the same process?
Frequently asked questions
Is the “Queue Concepts and Drivers” lesson free?
Yes — the full text of “Queue Concepts and Drivers” is free to read here on the web, and the PHP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the PHP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Queue Concepts and Drivers”?
Understand async processing and configure database or Redis queue drivers. You practise PHP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start PHP Academy?
No prior experience is required. PHP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Queue Concepts and Drivers” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this PHP Academy lesson?
Yes. Every PHP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Queue Concepts and Drivers
- Creating and Dispatching Jobs
- Job Retries, Delays, and Chaining
- Monitoring Queues with Laravel Horizon