Distributed Execution
Run workflow tasks across multiple worker nodes.
Architecture
Server-side services
┌───────────┬───────────┬─────────────┐
│ Scheduler │ Web UI/API│ Coordinator │── Persistent server data
└───────────┴───────────┴──────┬──────┘
│ gRPC
┌────────────────┼────────────────┐
│ │ │
Worker 1 Worker 2 Worker 3
(gpu=true) (region=eu-west) (cpu-optimized)
local work local work local workWorker Data Flow
Workers require explicit coordinator addresses. The coordinator dispatches DAG definitions and receives status, logs, artifacts, heartbeats, and persistent-state requests over gRPC. Workers do not mount server data or the server DAG directory.
DAG definitions are transmitted with dispatched tasks. When a step needs scripts, configuration, or other files stored beside its DAG, declare file dependencies. Dagu snapshots those files and materializes them in the worker's run directory.
Workers stream step and scheduler logs while a run is active, so the Web UI can display them before completion. Small bursts are briefly batched to reduce gRPC traffic, and any remaining output is sent when execution completes.
See Workers for configuration and Worker Deployment for deployment examples. Existing shared-filesystem worker installations should follow the migration guide.
How Dispatch Decisions Work
Every server-side execution path in Dagu (API, scheduler, queue, and sub-DAG steps) uses a single function (ShouldDispatchToCoordinator) to decide whether a DAG runs locally or is dispatched to a worker. This guarantees consistent behavior for runs handled by the server and queue processor.
Decision Priority
The dispatch decision evaluates these rules in order, stopping at the first match:
| Priority | Condition | Result |
|---|---|---|
| 1 | worker_selector: local is set | Local: always runs on the main instance |
| 2 | No coordinator is configured | Local: distributed execution is unavailable |
| 3 | worker_selector has labels (e.g., gpu: "true") | Dispatch: sent to a matching worker |
| 4 | default_execution_mode: distributed is set | Dispatch: sent to any available worker |
| 5 | None of the above | Local: runs on the main instance |
A run bound to a worker node goes to that worker by its ID, whatever these rules say. With coordinator.enabled: false, such a run fails before it starts. See Node Targeting.
Execution Paths
All of the following entry points evaluate the same decision logic:
| Trigger | Description |
|---|---|
| API start | Immediate execution from the UI or API |
| API retry | Retrying a failed run from the UI or API |
CLI dagu enqueue | Queueing a DAG-run from the command line for the queue processor to dispatch |
| Scheduler | Cron-triggered scheduled runs |
| Queue consumer | Dequeuing a previously enqueued run |
| Sub-DAG step | A call step executing a child DAG |
Queue Behavior
When a DAG run is enqueued (via API, webhook, or scheduler), it always enters the local queue first with status queued. The queue processor dequeues items respecting max_concurrency, and only at dequeue time does it evaluate the dispatch decision. This means distributed runs are still subject to queue concurrency limits: the queue acts as a gate before dispatch, not after.
Sub-DAG Dispatch
Each sub-DAG independently evaluates the dispatch decision. A DAG running locally can dispatch a child to a worker (if the child has worker_selector labels), and a DAG running on a worker can force a child to run locally (if the child has worker_selector: local). Parent and child dispatch decisions are independent, whether the child is started synchronously with action: dag.run or queued asynchronously with action: dag.enqueue. A parent running on a worker cannot use action: dag.enqueue, though: a worker has no queue to put the child run in.
Transport Security
With Dagu 2.28.0 or later, coordinator traffic uses built-in TLS wherever a process can get the coordinator's CA:
- Processes that share the coordinator's data directory, such as
dagu start-allor a scheduler beside the coordinator, use it with no setting. - A worker on another host joins with an invite and connects with its own worker certificate.
- A worker with neither connects over plaintext gRPC. System Status shows it with the change that moves it to TLS.
Treat worker connectivity as a control plane. Anyone who can intercept or impersonate that channel can affect workflow execution.
For Kubernetes, private network, VPN, overlay network, and SSH forwarding examples, see Distributed Networking. For invites, your own certificates, and mTLS, see Distributed Transport Security.
Setting Up Distributed Execution
Step 1: Start the Coordinator
The coordinator service is enabled by default in dagu start-all:
# Expose the coordinator to remote workers
dagu start-all \
--coordinator.host=0.0.0.0 \
--coordinator.advertise=<coordinator-address> \
--port=8080
# Disable the coordinator when distributed execution is not needed
DAGU_COORDINATOR_ENABLED=false dagu start-all
# Or start coordinator separately
dagu coordinator \
--coordinator.host=0.0.0.0 \
--coordinator.advertise=<coordinator-address> \
--coordinator.port=50055By default, the coordinator binds to 127.0.0.1. Set a reachable bind and advertise address before connecting workers from another host or container.
For containerized environments (Docker, Kubernetes), configure both the bind address and advertise address:
# Bind to all interfaces and advertise the service name
dagu coordinator \
--coordinator.host=0.0.0.0 \
--coordinator.advertise=dagu-server \
--coordinator.port=50055 \
--coordinator.health-port=8091--coordinator.host: Address to bind the gRPC server (use0.0.0.0for containers)--coordinator.advertise: Address workers use to connect (defaults to hostname if not set)--coordinator.health-port: Dedicated HTTP/healthport for per-instance liveness checks (0disables)
If you need an independent coordinator health probe, run dagu coordinator as a separate service. dagu start-all keeps using the main web/API process health endpoint and does not expose the dedicated coordinator HTTP health server.
Step 2: Deploy Workers
Add each worker with Add worker in the Workers section of System Status, or create an invite on the server host with dagu worker invite. Both print the command to run on the worker host:
dagu worker invite --address <coordinator-address>:50055Start each worker on your compute nodes with its invite and labels:
# GPU-enabled worker
dagu worker \
--worker.coordinators=<coordinator-address>:50055 \
--worker.invite=<invite> \
--worker.labels gpu=true,cuda=11.8,memory=64G \
--worker.health-port=8092
# CPU-optimized worker
dagu worker \
--worker.coordinators=<coordinator-address>:50055 \
--worker.invite=<invite> \
--worker.labels cpu-arch=amd64,cpu-cores=32,region=us-east-1 \
--worker.health-port=8092A single-use invite enrolls one worker; dagu worker invite --reusable creates one for several. A restart reuses the worker's certificate while its data directory is kept, so it needs no new invite. See Add Workers With Invites.
Each worker exposes GET /health on its configured worker.health_port, which is intended for container-orchestrator liveness and readiness probes for that specific worker process.
Step 3: Route Tasks to Workers
Use worker_selector in your DAG definitions to route tasks:
worker_selector:
gpu: "true"
tools:
- astral-sh/uv@0.11.14
steps:
- run: uv run --python 3.13.9 python train_model.py
dependencies: train_model.pyOr at the step level for sub-DAG steps:
steps:
- action: dag.run
with:
dag: train-model
worker_selector:
gpu: "true"See Worker Labels for full details on label matching and step-level worker_selector.
Default Execution Mode
By default, DAGs without a worker_selector run locally on the main instance. You can change this behavior with the default_execution_mode server setting so that all DAGs are dispatched to workers automatically.
# config.yaml
default_execution_mode: distributed # "local" (default) or "distributed"Or via environment variable:
export DAGU_DEFAULT_EXECUTION_MODE=distributedWhen set to distributed, every DAG is dispatched to a worker through the coordinator, even if it has no worker_selector. DAGs with a worker_selector are always dispatched to a matching worker regardless of this setting.
Build workflows are local-only
type: build requires local file fencing and is rejected in distributed mode. When the server default is distributed, set worker_selector: local on each build workflow. See Build Workflows.
Human Tasks on Distributed Workers
Root DAGs containing action: human.task use normal dispatch rules. They may select a worker with a label-based DAG-level worker_selector, follow default_execution_mode: distributed, or remain local.
When a worker reaches a human task, it persists the final waiting state and releases the run. The Web UI, REST API, or local CLI can store the form input in the root run. When a completion unblocks a step or no manual steps remain waiting, Dagu enqueues the same run through the scheduler. This is the same queue-based resume path used for local runs; completion never starts a run directly. The scheduler must remain available. Human tasks are prohibited in sub-DAGs.
Force Local Execution
If default_execution_mode is distributed but you need a specific DAG to always run locally (e.g., a lightweight health-check), use worker_selector: local:
# This DAG always runs locally, even when default_execution_mode is "distributed"
worker_selector: local
steps:
- run: curl -f http://localhost:8080/healthSetting worker_selector to the string "local" overrides both the server default and any label-based routing, forcing the DAG to execute on the main instance.
See How Dispatch Decisions Work for the complete priority order.

