Craft CMS queue jobs

Published

Updated

How to run Craft CMS queue jobs in the background without blocking your application's PHP processes.

Craft CMS uses queue jobs for long-running tasks. By default, these jobs are processed by a web-based AJAX call that blocks PHP processes meant for site delivery. In the worst case, the queue runner consumes all available PHP resources. Better solutions are available.

The most common use case is image transforms.

Worker jobs

Run long-running processes in an isolated environment without affecting site delivery. The jobs component allows you to create a worker job to run in the background.

  1. Make sure the jobs component is booked
  2. Set up a job with this Craft command: php craft queue/listen --verbose
  3. Set runQueueAutomatically to false in config/general.php to disable the default queue processing

Hanging queue jobs

A queue that does not move indicates a problem. Check the queue in the Control Panel for failed or stuck jobs and their errors, and release or delete them there, as long as the site still responds. Bulk updates can add thousands of jobs at once, which keep the queue busy for a long time.

Alternatives

A lighter alternative is the Async Queue plugin. For many queue workloads, the ostark/craft-async-queue plugin can mitigate performance problems without needing an extra component or additional configuration.

The plugin may no longer be maintained. Its last release, 4.0.0, dates from April 2024. Test it with the Craft version in use, or prefer a worker job.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗