Menu

1 / 2

Laravel Queue: Understanding Retry, Backoff and Timeout

DEV Community: laravel·parsa raad·about 8 hours ago
#JENQ1aL5
#devtolaravel#devto#dev#php#backend
Long article (1317 words) — no AI summary yet.
Reading 0:00
15s threshold

Laravel Queues make it easy to move time-consuming tasks out of the main request lifecycle. But running jobs in the background introduces a few important questions:

What happens when a job fails?

How many times should Laravel retry it?

How long should Laravel wait before retrying?

What happens when a job takes too long to finish?

Understanding tries , backoff , timeout , and retry_after is essential when building reliable queue workers.

Let's look at each one.

1. Understanding Job Retries

Laravel allows you to control how many times a job can be attempted before it is marked as failed.

You can configure this at the worker level:

php artisan queue:work redis --tries=5

Enter fullscreen mode

Exit fullscreen mode

Or define it directly inside your job:

public function tries ( ) : int { return 5 ; }

Enter fullscreen mode

Exit fullscreen mode

This means Laravel can attempt the job up to five times.

One important detail: an attempt doesn't necessarily mean that the handle() method completed or even…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.