Skip to content

Run background jobs and queue workers

Sending email, processing uploads, generating reports, calling slow APIs — none of that should happen inside a web request (it causes 504 timeouts). Push it onto a queue and process it in the background.

Two ways to run a worker

Run the worker on a schedule, processing whatever’s waiting and then exiting. This needs no always-on process — just a cron job:

Laravel:

* * * * * php /home/orbix-you/app/artisan queue:work --stop-when-empty >> /dev/null 2>&1

--stop-when-empty drains the queue and exits, so each run is clean and cron restarts it next minute. Pair it with the scheduler.

Node / other: write a small script that pulls jobs and exits, and cron it the same way.

This handles the vast majority of workloads and is the easiest to reason about.

2. A persistent worker (for high throughput)

If you need jobs picked up instantly and continuously, run a long-lived worker process (e.g. queue:work without --stop-when-empty, or a dedicated Node worker). Run it as its own app/process so it’s kept alive and restarted on failure, and make sure it has a way to reconnect if the database or Redis blips.

Start with cron-driven; move to persistent only when latency demands it.

Use Redis as the queue backend

OrbixPanel ships Redis — a great, fast queue backend:

QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379

Rules of thumb

  • Keep web requests fast — enqueue the slow work and return immediately.
  • Make jobs idempotent — safe to retry if they fail partway.
  • Watch for failures — log failed jobs and alert on them.
  • Don’t starve the server — one or two workers on a small box; scale with load.

Running OrbixPanel? Redis is pre-installed as a queue backend, and cron drives your workers. OrbixPanel.com → — the free, self-hosted, AI-powered hosting control panel.