Which execution tool? β
Spawn is an execution substrate with several extension layers, and they solve different problems β they aren't ranked alternatives. Start here before diving into any individual guide; then follow the link.
The layers at a glance β
| Layer | The question it answers |
|---|---|
| Instance plugin | What software or service should exist on an instance? |
| Parameter sweep | How do I run one command over varying parameters? |
| Job array | How do I run indexed copies of the same workload? |
| Instance queue | How do I run several dependent steps sequentially on one machine? |
| Spawn pipeline | How do I run a DAG of coarse stages across different machines? |
| MPI cluster | How do I run tightly-coupled code across many nodes at once? |
Task (spawn task run) | How do I run one command from a spec that stages inputs from S3, runs, and stages outputs back? |
Worker pool (spawn pool) | How do I run many short tasks without booting an instance per task? |
| Workflow adapter | How does my existing workflow engine use spawn as its executor? |
By what you're trying to do β
| I want to⦠| Use |
|---|---|
| Install RStudio, Tailscale, or Globus on an instance | Instance plugin |
| Run one command over several parameter values | Parameter sweep |
| Divide one dataset into indexed shards | Job array |
| Run several steps on one instance (shared local data/env) | Instance queue |
| Use different machines for a few coarse stages | Spawn pipeline |
| Run tightly-coupled parallel code (one job, many nodes) | MPI cluster |
| Run one containerized or host command with S3 inputs/outputs and a durable completion record | spawn task run |
| Run many short tasks (hundreds or more) through reusable workers | spawn pool |
| Already have a Nextflow / WDL / CWL / Snakemake workflow | The matching adapter |
| Add one heavy compute step to a business/ETL DAG | Airflow operator |
| Run a large, complex scientific DAG | An established workflow engine via its adapter β not a spawn pipeline |
The two easy-to-confuse pairs β
Sweep vs. array. A sweep runs the same command over different declared parameter values (one instance per combination). An array runs the same workload with index-based partitioning: each member gets $JOB_ARRAY_INDEX and $JOB_ARRAY_SIZE and processes its own shard.
Instance queue vs. pipeline. An instance queue runs multiple dependent steps sequentially on one machine β ideal when the steps share large local files, packages, or model weights and you don't want to pay to boot (and re-stage) a machine per step. A pipeline runs a DAG across separate machines, so each stage can use different (and differently-sized) compute, with data handed off through S3.
When not to use a spawn pipeline β
spawn pipeline is a compact orchestrator for small, coarse, infrastructure-shaped DAGs β tens of stages, not millions of tasks. It deliberately does not do advanced caching, dynamic DAG generation, nested workflows, or a rich conditional language. For complex scientific pipelines (per-sample fan-out, scatter/gather, resume/caching semantics), use a real workflow engine through its adapter and let spawn be the executor underneath.
When per-task ephemeral instances fit β and when they don't β
Most layers here launch (and pay to boot) at least one EC2 instance per unit of work; spawn pool is the exception. That's a great fit for some shapes and a poor one for others:
- Good fit: tasks lasting tens of minutes to hours; heterogeneous resource needs per task; full-VM requirements; expensive accelerators you only want for the duration of the work.
- Poor fit: thousands of sub-minute tasks; extremely chatty workflows; tasks needing shared POSIX state; pipelines dominated by repeated environment setup. For those, prefer a worker pool, an instance queue (batch the steps onto one machine), or a standing cluster / AWS Batch.
Tasks and worker pools β
spawn task run runs one command described by a TaskSpec JSON file, the contract the workflow adapters use. spawn picks the cheapest instance type that fits (or the one you pin), stages inputs from S3, runs the command (inside a container if the spec names one), stages outputs back, and writes a durable completion record to S3 that spawn task status reads. The instance self-terminates when it's done.
Worker pools for many short tasks β
At high fan-out, one instance per task is dispatch-bound: every task pays a full boot, and short tasks finish faster than new instances launch. spawn pool inverts that. spawn pool create provisions N reusable workers and a run-scoped SQS queue; spawn pool submit stages a task spec and enqueues it; workers pull tasks until the queue is empty. A worker whose queue stays empty for --idle-timeout terminates, so nothing is left billing (since spawn v0.136.0; older workers were stopped instead). spawn pool status shows the queue depth, and spawn pool drain deletes the queue, after which each worker terminates at its next poll. Ask for N workers and get M, and the tasks still drain through whatever pool came up. See Tasks and worker pools and the command reference.
See also Costs & safety guarantees for how the TTL bounds the cost of any of these.