img

7 min read

Mastering Background Laravel Job Queues

Interested in generating passive income? Join our partnership program and receive a commission on each new client referral. Learn more.

Laravel job queuesModern web applications increasingly rely on background processing to remain fast, responsive, and scalable. Whether it’s sending emails, processing CSV imports, generating reports, or handling complex integrations - these tasks can be offloaded from the main user-facing layer using Laravel’s powerful queue system.

As Laravel’s official documentation puts it, queued jobs are processed asynchronously, allowing your application to respond with blazing speed. At Redberry, we’ve implemented Laravel job queues in everything from high-frequency fintech platforms to content-heavy enterprise apps. We rely heavily on tools like Laravel Horizon, Laravel Cloud queue clusters with intelligent autoscaling, and real-time queue monitoring to ensure seamless background processing at any scale.

In this blog, we’ll walk through why queues are essential, how to configure and monitor them for reliability, and how Redberry’s approach ensures fault-tolerant systems that can scale as your needs grow.

Why Use Laravel Job Queues?

Queues are one of the most important performance tools in Laravel’s ecosystem. They allow you to defer resource-intensive tasks and run them in the background, freeing the main application thread to serve users instantly.

Imagine a user uploads a CSV file with 10,000 rows. Without Laravel job queues, the application would need to process that file during the HTTP request, potentially making the user wait for 30 seconds or more. Instead, Laravel allows you to immediately return a response like “Your import is being processed” and push the processing logic into a queued job:

ProcessCsv::dispatch($filePath);

That single line of code offloads the task to a background worker. This design pattern improves user experience dramatically, especially under heavy load or concurrent usage.

Real-world scenarios where we’ve leveraged this include:

  • Sending bulk emails via job batches.
  • Importing thousands of SKUs in e-commerce systems.
  • Triggering post-purchase integrations with third-party tools.
  • Generating large, paginated reports in the background.

Queues are foundational to building fast, responsive, and scalable Laravel applications.

Configuring Queue Connections

Laravel supports several queue backends out of the box: Redis, database, Amazon SQS, Beanstalkd, and more. Choosing the right one depends on your app’s scale and infrastructure.

At Redberry, we typically use Redis for its speed and support for advanced queueing features. The configuration lives in config/queue.php, where you define your default connection:

'default' => env('QUEUE_CONNECTION', 'redis'),

Each connection defines a queue driver, retry settings, and other options. Redis supports multiple queues and priority levels, allowing us to handle critical jobs (like payments or security alerts) separately from non-urgent ones (like report generation or analytics).

Here’s a simplified example of a Redis connection config:

'redis' => [
    'driver' => 'redis',
    'connection' => 'default',
    'queue' => 'default',
    'retry_after' => 90,
    'block_for' => null,
],

You can also define multiple named queues (emails, webhooks, imports) and assign jobs to specific ones for better workload separation.

Running and Supervising Workers

To process jobs, Laravel spins up queue workers - background processes that poll your queue and execute jobs. At Redberry, we run our workers using php artisan horizon and supervise them using systemd for production-grade stability.

We typically set up:

  • Separate worker processes for high-priority queues.
  • Multiple workers for batch-heavy systems (e.g., 4 workers on emails, 1 worker on pdf-generation).
  • Retry and timeout configurations to handle failures gracefully.

A systemd service file might look like:

[Service]
ExecStart=/usr/bin/php /var/www/project/artisan horizon
Restart=always

With systemctl, we can start, stop, or restart workers cleanly and ensure they boot automatically after server reboots.

Monitoring Queues with Horizon and Nightwatch

Laravel Horizon is a game-changer when it comes to monitoring Redis-based queues. It provides a sleek, real-time dashboard where you can:

  • See active and pending jobs.
  • Monitor queue throughput.
  • Track job failures and retries.
  • View time-to-completion metrics per job type.

At Redberry, we use Horizon extensively in nearly all Redis-powered Laravel apps. For example, in an enterprise platform that triggers 1,000+ jobs per hour, we rely on Horizon to dynamically scale workers when a spike is detected. We also tag jobs (EmailJob, DataImportJob, SyncJob) to track queue behaviour per module.

More recently, we’ve implemented Laravel Nightwatch in several client projects. It builds on Horizon’s functionality, adding job tracing, deeper analytics, and long-term insights - especially useful for systems with unpredictable traffic.

And in Laravel Cloud, the newly introduced queue clusters offer intelligent autoscaling. We’ve begun adopting these in production environments, letting Laravel Cloud scale workers dynamically based on job backlog and queue load. This means no more guessing how many workers you’ll need during a product launch or marketing campaign - it just scales.

Explore Laravel Cloud Queue Clusters →

Handling Failures and Retries

Even the best background systems need failure handling. Laravel offers robust features for retrying failed jobs, backing off aggressively, and alerting your team when something goes wrong.

Key concepts include:

  • Retry count: How many times Laravel should retry a job before marking it as failed.
  • Backoff delay: How long Laravel waits between retries (backoff property on the job).
  • Failed job table: Where Laravel logs permanently failed jobs for later inspection.

We also implement job-level exception handling to:

  • Delete sensitive or temporary files if a job fails.
  • Report failures to external monitoring tools (like Sentry).
  • Send Slack notifications on critical job failures.

In apps dealing with payments or API integrations, this level of error handling is non-negotiable.

Using Job Batching for Complex Workflows

Laravel’s job batching system is perfect for large, interdependent workflows. For example, when onboarding a new enterprise client to a SaaS product, we might:

  1. Import their users.
  2. Import historical data.
  3. Generate onboarding analytics.

These are all individual jobs, but we batch them and track the overall success or failure using Laravel’s batching API:

Bus::batch([
    new ImportUsers,
    new ImportData,
    new GenerateReports,
])->then(function () {
    // Notify client onboarding is complete
})->dispatch();

We also use job chains to ensure that one job runs only after the previous one succeeds.

This pattern makes complex background workflows easier to reason about, monitor, and retry if necessary.

Real-World Example: SOCAR Mobile App

When we helped develop SOCAR’s mobile app, used by thousands of drivers to reserve and refuel their cars across the city, background   played a key role in maintaining speed and scalability.

From sending OTPs and transaction receipts to syncing external fueling stations and processing location data, we handled a wide array of tasks via Redis-backed jobs. Our team used Laravel Horizon to visualize and manage traffic spikes, while custom retry logic ensured that mission-critical processes (like payment confirmations) never got lost due to a temporary outage.

By decoupling critical operations from user requests, we ensured that SOCAR’s app remained fast and reliable even during peak usage hours - an essential feature for a fuel station network that operates 24/7. Learn more about SOCAR’s case here.

Conclusion

Mastering background Laravel job queues is essential to building high-performance Laravel applications. By offloading heavy tasks to well-monitored queues, you not only deliver faster user experiences but also gain flexibility and fault tolerance across your infrastructure.

At Redberry, we’ve spent a decade refining our use of Laravel’s queue ecosystem - from Redis and Horizon to Nightwatch and Laravel Cloud queue clusters. As official partners of Laravel, Vue, and Filament, we stay at the forefront of what the Laravel ecosystem has to offer, ensuring our clients benefit from best-in-class performance, maintainability, and scalability.

Need help implementing background processing in your Laravel app - or just want your platform to scale without breaking? Explore our Laravel Web App Development services. We’d love to help.

img

Meet the authors

We are a 200+ people agency and provide product design, software development, and creative growth marketing services to companies ranging from fresh startups to established enterprises. Our work has earned us 100+ international awards, partnerships with Laravel, Vue, Meta, and Google, and the title of Georgia’s agency of the year in 2019 and 2021.

img
CONTACT US