Skip to content
Docs

Workers

Run Laravel's queue, Celery or any long-running command beside your app. Up to 5 workers an app, each paying only for what it uses.

Updated 17 Oct 20263 min read

A worker is a second process of your app that runs all the time but never takes visits: a queue consumer, a bot, a script that watches something. It runs from your app's live version, with the same files and variables, and pays only for the memory and processor time it really uses. An app can have up to 5 workers.

An app's processes

ProcessHow manyWhat it does
WebOne per appStarted with your start command. Visitors reach it on port 8080.
WorkersUp to 5Run all the time, beside the web process, for queues and other background work
Scheduled tasksUp to 10Run a command on a timetable, then stop. See Scheduled tasks.

You see them all on the app's page, under Processes. Each restarts by itself if it stops.

Add a worker

  1. Open the app's page. Under Processes, choose Add a worker or scheduled task.

  2. For Kind, choose Worker.

  3. Give it a Name: lowercase letters, digits and dashes, starting with a letter, like queue.

  4. Type its Command.

  5. Under Limits, keep The app's limits, or choose Limits of its own.

  6. Choose Save and restart.

The app restarts with its new worker, without downtime for your visitors. A worker added before the app's first deploy shows Waiting for a deploy until there's a live version to run.

Commands for common frameworks

FrameworkWorker command
Laravelphp artisan queue:work --tries=3 --max-time=3600
Laravel Horizonphp artisan horizon
Django with Celerycelery -A shop worker --loglevel=info
Node.js with BullMQnpm run worker, with a worker script in package.json

--max-time=3600 makes Laravel's worker stop after an hour, and it starts again by itself: a simple way to free memory a long-running worker may hold.

Example: Asha's queue

Asha's shop sends its order emails from Laravel's queue, through a Valkey database used for queues. She adds a worker named queue with php artisan queue:work --tries=3 --max-time=3600 and the app's limits. When a customer orders, the web process puts the email on the queue and answers at once; the worker sends it a second later.

Her worker shows Running under Processes. Its lines appear in the project's logs, next to the web process's, so she can search for a failed job.

Limits and price

A worker uses The app's limits unless you give it Limits of its own. Either way, limits are only ceilings: it pays for the memory and processor time it really uses, every hour, like the web process. A worker that waits for jobs most of the time costs little. See Limits.

When a worker stops

A worker that stops is started again, after 1, 2, 4 seconds and longer, up to a minute apart. If it stops 5 times within 10 minutes, it shows Keeps crashing, we stop starting it, and you're told under the bell and, if you choose so in your alerts, by email. Deploy a fix, or start it again.

Things to know

  • A worker's files are the app's: changes it writes outside the permanent folders are gone on the next deploy.

  • A running worker keeps a sleeping app awake.

  • To look inside a running worker, open a terminal and choose it under Process.

  • To remove one, choose Remove: the app restarts without it.