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 |
sync_executor | SyncExecutor | THREAD | Executor for sync tasks: THREAD or PROCESS |
redis_url | str | None | Redis URL (falls back to UPNEXT_REDIS_URL env var) |
queue_config | WorkerQueueConfig | None | None | Optional per-worker queue overrides (otherwise uses UPNEXT_QUEUE_*) |
Queue tuning
Queue behavior is tuned withUPNEXT_QUEUE_* environment variables. These values are read when the worker initializes.
| Variable | Default | Description |
|---|---|---|
UPNEXT_QUEUE_BATCH_SIZE | 4 | Number of jobs fetched/flushed per batch |
UPNEXT_QUEUE_INBOX_SIZE | 4 | In-memory fetch buffer size (minimum is batch size) |
UPNEXT_QUEUE_OUTBOX_SIZE | 10000 | In-memory completion buffer size |
UPNEXT_QUEUE_FLUSH_INTERVAL_MS | 5.0 | Max delay before flushing completed jobs |
UPNEXT_QUEUE_CLAIM_TIMEOUT_MS | 30000 | Idle time before stale jobs are reclaimable |
UPNEXT_QUEUE_JOB_TTL_SECONDS | 86400 | TTL for job payload/index/dedup keys |
UPNEXT_QUEUE_STREAM_MAXLEN | 0 | Redis stream trim cap (0 means unbounded) |
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.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.