Tasks
A task is a single unit of work — a function registered with Hatchet that can be enqueued, executed, retried, and observed. Every task execution is persisted to Postgres. A task has:- Typed input — validated via Pydantic (
BaseModel) in Python, a plain type in TypeScript/Go. - Typed output — the return value of the function, also persisted.
- Retries — configurable retry count on failure.
- Timeouts —
execution_timeoutlimits how long the task can run;schedule_timeoutlimits how long it can wait in the queue before being picked up. - Priority — integer (1–3) controlling relative ordering within a queue.
Workflows
A workflow is a named collection of tasks that can be triggered together. When you use@hatchet.task(...) directly, Hatchet creates a standalone single-task workflow automatically. When you need multiple tasks to run in sequence or in parallel, you define a multi-task workflow explicitly.
Workflows can be triggered:
- Manually — by calling
.run()or.aio_run()from your application code. - By event — via
on_eventsin the workflow config, when a matching event key is published. - On a schedule — via
on_cronsor by calling.schedule()for a one-time future run.
Workers
A worker is a long-running process that connects to the Hatchet server, registers the workflows it can handle, and polls for tasks to execute. Workers are your application code — Hatchet dispatches tasks to them over a persistent connection. Key worker properties:- Slots — the number of concurrent task runs the worker will accept at once. A worker with
slots=10can execute up to 10 tasks in parallel. - Workflow registration — a worker only executes the workflows it was started with. Tasks for unregistered workflows are routed to other workers.
You can run multiple worker processes — even on different machines — all registered to the same workflow. Hatchet will distribute tasks across them.
DAGs
A DAG (directed acyclic graph) is a workflow where tasks have explicit parent-child dependencies. When a parent task completes, its output is automatically available to child tasks viactx.task_output(). Tasks with no parents run immediately; tasks with parents wait until all parents have succeeded.
Durable execution
Durable tasks are a special task type (@hatchet.durable_task()) designed to orchestrate long-running or event-driven work. They store a full history of all spawned sub-tasks, which means:
- If your worker crashes mid-execution, the task resumes from the last checkpoint rather than restarting from scratch.
- A durable task can sleep for a duration without holding a worker slot.
- A durable task can wait for an external event before continuing.
Flow control
Hatchet provides two primitives for protecting your system from overload.Concurrency limits
Set a maximum number of concurrent runs for a workflow, optionally scoped to a dynamic key (such as a user ID) using a CEL expression.GROUP_ROUND_ROBIN— distribute slots evenly across concurrency groups.CANCEL_IN_PROGRESS— cancel the currently running task when the limit is hit.CANCEL_NEWEST— reject the incoming task when the limit is hit.
Rate limits
Rate limits cap how many task executions are allowed in a time window. Like concurrency, they support dynamic keys so you can apply per-user or per-tenant limits:Scheduling
Hatchet supports three scheduling mechanisms:Cron schedules
Run a task on a repeating cron schedule:One-time scheduled runs
Schedule a task to run at a specific future time:Event-triggered runs
Configure a workflow to start automatically when a matching event key is published:All concepts at a glance
Tasks
Functions registered with Hatchet, with typed inputs/outputs, retries, and timeouts.
DAGs
Multi-step workflows with parent-child dependencies and automatic output routing.
Durable execution
Long-running tasks that sleep, wait for events, and resume after crashes.
Workers
Processes that register workflows and execute tasks dispatched by the Hatchet server.
Flow control
Concurrency limits and rate limits scoped globally or per user/tenant.
Scheduling
Cron, one-time, and event-based triggers for your workflows.