Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cloud.laravel.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

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.
A new fully managed queues solution is currently available in early access. To request access, contact Laravel Cloud support.

Queue processing options

Laravel Cloud offers two approaches for processing queued jobs:
FeatureWorker ClustersApp Cluster Background Processes
Queue IsolationSeparated from web trafficShared with web traffic
Auto-scalingCPU/RAM based scalingCPU/RAM based scaling
Best for: Medium to high-volume processing separated from web traffic Worker clusters let you run php artisan queue:work in a dedicated cluster that is isolated from the compute handling your application’s web traffic. Worker clusters can also manage additional scheduled tasks and custom background processes, and scale based on CPU/RAM usage. Learn more about creating worker clusters

App cluster background processes

Best for: Development and low-volume processing Run php artisan queue:work as a background process in your all-in-one App cluster alongside your web application. Cost-effective, but queues compete with web traffic for resources.

Creating queue workers on worker clusters

Running your application’s queue workers on a dedicated Worker cluster, rather than on the App cluster that handles incoming HTTP traffic, allows you to scale queue processing independently of your web traffic. To add queue workers to a dedicated Worker cluster, first create the Worker cluster. Then, click on the Worker compute cluster within the infrastructure canvas dashboard. 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.

Queue clusters

Queue clusters are no longer available for new environments. Existing queue clusters will continue to operate, but we recommend running queue workers on a Worker cluster or App cluster background process instead.
Queue clusters run php artisan queue:work in a fully isolated cluster whose sole purpose is running and intelligently scaling queue worker processes based on job latency and queue depth. If you have an existing queue cluster, it will remain visible within your environment’s infrastructure canvas and continue processing jobs. New queue clusters cannot be created.

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.