Create a worker
Instantiateupnext.Worker to create a worker:
- A Redis-backed queue for receiving jobs
- A job processor that executes task, event, and cron functions
- Cron schedulers for recurring work
- Event routers for pub/sub handlers
Worker options
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | auto-generated | Worker name for dashboard identification |
concurrency | int | 2 | Maximum concurrent job executions |
prefetch | int | None | Jobs to prefetch from queue (auto-tuned by default) |
sync_executor | SyncExecutor | THREAD | Executor for sync tasks: THREAD or PROCESS |
sync_pool_size | int | None | Size of the sync executor pool |
redis_url | str | None | Redis URL (falls back to UPNEXT_REDIS_URL env var) |
secrets | list[str] | [] | Secret names to fetch on startup (requires server) |
Run a worker
Workers are started withupnext.run() or the CLI:
Scaling
Run multiple worker instances pointing at the same Redis — UpNext distributes jobs automatically.XREADGROUP, so no two workers process the same job. If a worker crashes, its pending jobs are automatically recovered by other instances.
Each instance manages its own concurrency independently:
rate_limit and max_concurrency are enforced across the entire cluster, not per-instance — so max_concurrency=10 means 10 total, regardless of how many workers are running.
Job types
Workers execute three kinds of jobs. Each has its own decorator and behavior:Tasks
One-off background jobs with retries, timeouts, and result handling.
Events
Pub/sub handlers that trigger when an event is published.
Cron Jobs
Recurring jobs on a schedule with standard cron syntax.