Manage workers
Deploying new worker code, keeping versions compatible, and knowing what the fleet is doing.
Deploy without losing work
Replace workers a few at a time; the others keep serving the queues.
- Start workers with the new code.
- Send SIGTERM to the old ones and wait. A worker stops polling, finishes what it holds (the tasks it had prefetched too), reports and deregisters, within
drain_timeout(30 seconds by default). - Give the platform a stop timeout above that. A kill before the worker is done does not lose the task: its lease expires and it runs again, with one retry used.
A task that needs longer than the drain is cut off and run again. Keep tasks short, or raise drain_timeout and the stop timeout together.
A graceful stop. The platform's stop timeout must be longer than the worker's drain.
Deploying a queue worker and a workflow worker
The steps above are the same for both. What differs is what a deploy can break:
| Queue worker | Workflow worker | |
|---|---|---|
| New code takes effect | At the next job | For runs started after the new blueprint is registered. Runs in flight keep the blueprint they started with |
| Old and new side by side | Safe if both can read the jobs already queued | Safe for the blueprint. Keep the handlers of steps that runs in flight still need |
| A task cut off by a kill | Runs again, one retry used | Runs again only if the step declares retries |
| Stopping every worker | Jobs wait | Runs wait at their step, and can time out |
So for a workflow worker: declare retries on steps, and do not remove or rename a step's handler while runs that use it are open.
Changing workflow code
Runs in flight outlive a deploy. A run keeps the blueprint it started with: a worker that registers a changed blueprint gets a new version, and only runs started after that use it. So old and new workers can run side by side during a rollout.
Versions that must match
A worker talks to a server of its own SDK version or later: an older server drops the blueprint fields it does not know. So upgrade the server first, then the workers. See Upgrading.
The SDK token
Every worker and producer sends the one SDK token. Pass it as a secret. Rotating it means restarting the workers with the new value: see Secrets.
Watch the fleet
- The Workers page lists every live worker with its queues, version, uptime and busy slots. A worker that stops registering disappears from it.
- Metrics:
joobqui_workers_registeredat 0 means no worker is alive.joobqui_queue_sizeandjoobqui_queue_deadgrowing mean the workers are too few, or failing. See Monitoring. - Alerts (Pro) turn those into notifications: see Alerts.
- Dead letters are where failed work ends up: see Dead letters.