Courses

Queues in Laravel 12

Long-Running Jobs: Timeouts, Fatal Errors and a Better Way

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Understanding how long-running jobs can reach timeout limits (default 60 seconds)
- Setting custom timeout periods using --timeout flag or the $timeout property
- Breaking down large jobs into smaller, more manageable jobs to avoid timeouts
- Passing only necessary data to jobs to keep payloads small and more efficient

Link to the repository

[Only for premium members]

When working with Laravel queues, you'll inevitably encounter scenarios where jobs take a long time to complete. In this lesson, we'll examine the challenges of long-running jobs, potential issues that can arise, and best practices for handling them effectively.


Understanding Long-Running Jobs

Long-running jobs are queue jobs that take many seconds or even minutes to complete. These could include operations like:

  • Generating reports for thousands of users
  • Processing large batches of data
  • Creating multiple files or documents
  • Performing complex calculations

These jobs present unique challenges, particularly with timeouts and error handling.


The Problem with Long-Running Jobs

Let's examine a practical example: generating monthly invoice PDFs for all customers. This could be thousands of documents that need to be created once per month.

Here's an implementation using...

The full lesson is only for Premium Members.
Want to access all 15 lessons of this course? (46 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord