Interview frequency: …
Short answer
It retries a job according to $tries; if it continues to fail, it records it in failed_jobs and calls failed() for cleanup or alerts.
Explanation
An exception in handle() fails the attempt. If public int $tries = 3 is set, the worker retries. With public array $backoff = [10, 30, 60], each retry is delayed progressively to reduce pressure on unavailable services. If all attempts fail, Laravel moves the job to failed_jobs and calls failed(Throwable $e) to alert the team or roll back operations.
Code example
class ProcessPayment implements ShouldQueue {
public int $tries = 3;
public array $backoff = [30, 60, 120];
public function failed(Throwable $exception): void {
Log::critical("Payment job failed permanently: " . $exception->getMessage());
}
}Common mistakes
- Setting an unlimited number of attempts for a job that fails due to a persistent Logic Error, freezing Queue Workers.
Follow-up questions
- What is the main difference between php artisan queue:work and queue:listen?
- How do you handle Stuck Jobs, and how does a job's $timeout differ from a worker's --timeout?