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…