Understanding Jobs and Queues in Laravel

11 Sep 2026 | Basile Aelterman

Tired of slow response times for tasks like sending newsletters? In this blog post I'll go over both jobs and queues, explain what they are, why, and how you should use them in your Laravel application.

Jobs

What Are Jobs?

In simple terms, jobs are basically tasks that are ran by the server. A task can be, for example, sending an email to someone, creating and storing an invoice, fetching an API, etc. These jobs can either be ran independently, or queued to a queue (I'll get into that soon) that runs them asynchronously.

Creating A Job

To create a job, first run the following command in your terminal:

php artisan make:job SendNewsletter

This creates a file inside ~/app/Jobs.

You will also notice that the class also implements the Illuminate/Contracts/Queue/ShouldQueue interface. By default, jobs are pushed to the queue to be run asynchronously. You can disable this (though not recommended) by getting rid of that interface, and also by removing the use Queueable statement inside the class.

To make your job actually do something (like sending an email), we place our code inside the handle method.

public function __construct(protected Subscriber $subscriber)
{
//
}

public function handle(): void
{
Mail::to($this->subscriber->email)->send(new NewsletterMail());
}

Using Jobs

We can use a job like this:

SendNewsletter::dispatch($subscriber);

Why Use Jobs?

Instead of manually writing code that does something every time, Jobs make you only need to write the logic once, and reuse it anywhere (DRY).

Queues

What Are Queues?

Queues are a collection of jobs that are stored and ran either instantly, or later in time. Sometimes, these jobs can take a while to perform. For example, let's imagine that you want to send a newsletter to all your subscribers. With only 5 people, this shouldn't take longer than a second. However, if you have thousands of people who are subscribed to your newsletter, this can take way longer. This is where queues come into play; You run a job (send the newest newsletter to everyone), and the queue handles it in the background. This way you don't have to wait for the task to finish before getting back a response from the server.

Setting Up The Queue

Setting up a queue in Laravel is pretty straightforward. To let the queue work, simply run the following command in your terminal:

php artisan queue:work

That's it. Whenever a task is dispatched to your queue, it will execute that task asynchronously. One thing to point out: when you're queue is currently working, it won't react to any of your code changes, meaning that if you make any changes you'll have to also restart your queue.

Failing Jobs

A job might, of course, still fail. Even though you got a success message from the server. This can and will realistically happen. Luckily for us, failed jobs can be found in the failed_jobs table. These jobs can also be ran again using the following command:

php artisan queue:retry all

This will push all failed jobs back to the queue to be retried.

Wrapping Up

Jobs are generic tasks that need to be run time and time again, and queues are a list of jobs that are queued up to be ran. Together, they make your UX better by providing quicker response times for the end-user and improving reliability by being able to rerun failed jobs.

It's highly recommended to implement the both in your next Laravel application, but it's still up to you to decide whether you need this or not.




Happy coding!

Basile Aelterman

Basile Aelterman

Software Engineer