Web apps & software

What is a queue worker?

A queue worker is a long-running process whose only job is to take tasks from a queue, execute them one after another and report success or failure. Adding more workers lets a system process more background work in parallel.

Keeping workers alive

Workers run continuously, so something must restart them if they crash or are stopped by a deployment. On Linux servers that is typically systemd, Supervisor or a process manager such as PM2; in containers it is Kubernetes or the platform's own service runner. After each deploy, workers must be restarted, otherwise they keep running yesterday's code, a classic source of "the fix is live but the bug is still happening".

Sizing and priorities

  • Run separate queues for urgent and bulk work, so a 50,000-email newsletter does not delay password-reset messages.
  • Scale the number of workers on queue length or job age, not on CPU alone.
  • Limit concurrency for jobs that call rate-limited APIs.

What to monitor

Queue depth, oldest-job age, failure rate and memory use per worker. Long-running PHP and Node.js workers can leak memory over hours; many frameworks offer a setting to restart a worker after a number of jobs or a time limit. Graceful shutdown matters too: on a deploy, a worker should finish its current job before exiting, so no task is cut off halfway through.

Questions, answered

Enough that the queue empties faster than it fills at peak times; measure rather than guess.

Yes, and separating them stops heavy jobs from slowing down page responses.

By the Stegnor team · Updated