Introduction

The Laravel queue is one of the most popular features of the framework, and Laravel Cloud makes it simple to start queue workers to process jobs that are dispatched by your application for background processing.

Queue Processing Options

Laravel Cloud offers three approaches for processing queued jobs:
FeatureQueue ClustersWorker ClustersApp Cluster Background Processes
Queue IsolationFully dedicated to specific queuesShared with other background processesShared with background processes and web traffic
Auto-scalingIntelligent scaling based on job latencyCPU/RAM based scalingCPU/RAM based scaling
Best for: High-volume processing with intelligent scaling Queue clusters run php artisan queue:work in a fully isolated cluster whose sole purpose is running and intelligently scaling queue worker processes. Queue clusters do not compete with your application’s web traffic or other scheduled tasks for resources. Learn more about queue clusters

Worker Clusters

Best for: Medium-volume processing separated from web traffic Worker clusters provide a middle ground where you can run php artisan queue:work in a cluster separated from web traffic, but worker clusters can also manage additional scheduled tasks and custom background processes that compete for cluster compute. Worker clusters scale based on CPU/RAM rather than queue depth and latency. Learn more about creating worker clusters

App Cluster Background Processes

Best for: Development and low-volume processing Allow you to run php artisan queue:work in an all-in-one cluster alongside your web application. Cost-effective but queues compete with web traffic for resources.

Queue Clusters (Developer Preview)

Queue clusters are currently in developer preview. Features and pricing may change as we gather feedback from customers.
Queue clusters provide intelligent auto-scaling for specific queues to ensure jobs are always processed as quickly as possible. Unlike other approaches, queue clusters automatically scale worker processes based on job latency and queue depth, guaranteeing your critical jobs never get stuck waiting.

Key Benefits

  • Intelligent Scaling: Automatic scaling based on job latency and queue depth
  • Dedicated Infrastructure: Completely isolated from your application’s web traffic
  • Fully Managed: No manual configuration of worker processes or scaling rules required

When to Use Queue Clusters

Queue clusters are ideal for:
  • Production Applications: High-volume job processing with reliability requirements
  • Priority Job Separation: Isolating critical jobs from general application traffic
  • Variable Workloads: Applications with unpredictable queue volumes that benefit from auto-scaling

Creating a Queue Cluster

To create a new queue cluster, navigate to your environment’s infrastructure canvas and click “New queue cluster”. Configure your compute resources and queue settings based on your application’s requirements. The queue cluster will automatically scale the number of worker processes based on job latency and queue depth to ensure jobs are processed immediately. For pricing information, see the compute section of our pricing page.

Creating Queue Workers on Worker Clusters

Instead of processing your application’s queued jobs on the App compute instance that also handles your application’s incoming HTTP traffic, you may add queue workers to dedicated Worker clusters. Processing queued jobs on Worker clusters allows you to scale those clusters independently of the App cluster which handles your web traffic. To add queue workers to a dedicated Worker cluster, you should first create the Worker cluster. Then, click on the Worker compute cluster within the infrastructure canvas dashboard. Then, within the “Background processes” section of your cluster settings, click “New background process”. Next, configure your queue worker options based on your environment’s requirements and select the number of queue:work processes within the given configuration that you would like to create. Finally, save and deploy your environment changes to start your queue worker.
Custom processes, including queue workers, will be spawned for each instance of your application or worker cluster, depending on your autoscaling configuration.For example, given an application that scales to 5 replicas, a queue:work process configured with 10 processes, would create 50 processes total. Smaller compute instances may consume excess memory through these additional workers, potentially creating unnecessary replica scaling.

Creating Queue Workers on App Clusters

The simplest way to begin processing queued jobs is to add a queue worker background process to your environment’s App compute cluster. When running queue workers on your App compute cluster, queued jobs will be processed on the same compute instances that handle your application’s incoming HTTP traffic. To get started, click on your environment’s App compute cluster within the infrastructure canvas dashboard. Then, within the “Background processes” section of your cluster settings, click “New background process”.
Next, configure your queue worker options based on your environment’s requirements and select the number of queue:work processes within the given configuration that you would like to create. Finally, save and deploy your environment changes to start your queue worker.
When running queue workers via Laravel Cloud, there is no need to run the queue:restart Artisan command after each deployment.

Custom Background Processes

In addition to configuring queue:work processes, Laravel Cloud also allows you to configure arbitrary long-lived custom background processes, such as Laravel Horizon. To get started, click on a compute cluster within your environment’s infrastructure canvas dashboard. Then, within the “Background processes” section of your cluster settings, click “New background process”. Next, click the “Custom worker” tab and provide your custom worker command and the number of instances of the command that should be started. For instance, for Laravel Horizon, you should provide the php artisan horizon command and specify that Laravel Cloud should create 1 process.
Finally, save and deploy your environment changes to start your custom worker process. Laravel Cloud will automatically restart the process if it exits prematurely.

Queue Workers and Hibernation

Queue workers will be paused on environments that are currently hibernating.