Laravel
Queue
Multitasking
Job Processing
Parallel Execution

Run multiple jobs at the same time using laravel queue

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Dispatching multiple Laravel jobs does not automatically make them run at the same time. Concurrency comes from your workers. One queue worker processes one job at a time, so if you want real parallel execution you need multiple worker processes or a Horizon configuration that allows several processes to run in parallel.

That distinction matters because many developers correctly dispatch five jobs and then wonder why they still run one after another. The queue is only the backlog. The workers are what create parallelism.

Dispatching Several Jobs

Here is a simple queued job:

php
1<?php
2
3namespace App\Jobs;
4
5use Illuminate\Bus\Queueable;
6use Illuminate\Contracts\Queue\ShouldQueue;
7use Illuminate\Foundation\Bus\Dispatchable;
8use Illuminate\Queue\InteractsWithQueue;
9use Illuminate\Queue\SerializesModels;
10
11class ProcessReport implements ShouldQueue
12{
13    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
14
15    public function __construct(public int $reportId)
16    {
17    }
18
19    public function handle(): void
20    {
21        sleep(10);
22        logger()->info("Processed report {$this->reportId}");
23    }
24}

Dispatch several jobs:

php
foreach ([101, 102, 103, 104] as $reportId) {
    ProcessReport::dispatch($reportId)->onQueue('reports');
}

At this point, the jobs are queued. They are not necessarily running in parallel yet.

One Worker Means One Job at a Time

If you start a single worker like this:

bash
php artisan queue:work redis --queue=reports

that worker will process the queued jobs sequentially. Laravel's queue documentation is clear about the model: workers pull jobs from the queue and process them. To increase concurrency, run multiple worker processes.

For example, start four workers:

bash
1php artisan queue:work redis --queue=reports
2php artisan queue:work redis --queue=reports
3php artisan queue:work redis --queue=reports
4php artisan queue:work redis --queue=reports

Now up to four jobs can be processed at the same time, assuming your queue driver and infrastructure can support it.

In production, you usually manage these workers with Supervisor or Laravel Horizon rather than manually opening several terminals.

Managing Parallel Workers in Production

With Supervisor, you can run multiple worker processes with a single config:

ini
1[program:laravel-reports]
2process_name=%(program_name)s_%(process_num)02d
3command=php /var/www/html/artisan queue:work redis --queue=reports --sleep=1 --tries=3
4autostart=true
5autorestart=true
6numprocs=4
7redirect_stderr=true
8stdout_logfile=/var/log/laravel-reports.log

If you use Horizon, configure the supervisor's process count there instead. Horizon is often the easiest way to monitor queues and scale worker concurrency on Redis-backed queues.

You should also verify that your queue connection is truly asynchronous. If the application is still using the sync driver in .env, no number of worker commands will help because jobs will execute inline during the web request.

Batches Help Coordination, Not Worker Count

If you want to dispatch many jobs as a logical unit, Laravel batches are useful:

php
1use Illuminate\Support\Facades\Bus;
2
3Bus::batch([
4    new ProcessReport(101),
5    new ProcessReport(102),
6    new ProcessReport(103),
7])->dispatch();

Batches help you track progress, failures, and completion callbacks. They do not by themselves create parallelism. The actual concurrency still depends on how many workers are running.

Common Pitfalls

  • Using the sync queue driver. With sync, jobs run immediately in the request and there is no background concurrency at all.
  • Running only one worker and expecting parallel job execution.
  • Putting CPU-heavy jobs on the same infrastructure without checking server capacity. More workers can also mean more contention.
  • Sharing mutable resources such as files or database rows without making the job logic concurrency-safe.
  • Assuming batches, chains, and queues are the same thing. Chains enforce order, while multiple workers create concurrency.

Summary

  • Laravel queues make background work possible, but workers create parallelism.
  • One worker handles one job at a time.
  • To run multiple jobs simultaneously, run multiple workers or scale Horizon processes.
  • Batches organize many jobs but do not replace worker concurrency.
  • If jobs still run sequentially, check the queue driver and the number of active worker processes first.

Course illustration
Course illustration

All Rights Reserved.