Repository navigation
Description
Use case
Running nf-core/taxprofiler on Graviton via nf-spawn (the aws-microbiome-demo). The Kraken2 step needs a ~16 GB k2_pluspf reference database on each task instance. Today the only way to get it there without a ~12 GB per-task download is to bake it into a custom AMI and point ext.ami at that.
That works, but welds three concerns into one artifact — OS image, tools, and a 16 GB data blob — and it's been genuinely awkward:
- A custom AMI per arch (x86 + arm64), each a separate bake.
- An arm64 AMI that initially lacked the DB, requiring a full AMI rebake just to add a data blob.
- Every task's root volume must be sized to hold the 16 GB DB even for steps that don't use it (fastp/FastQC/MultiQC), because the DB is on the root snapshot.
- DB updates force a machine-image rebuild instead of a data update.
What I'd like
Let a process attach a pre-populated EBS volume (from a snapshot) read-only at a mount point, on a stock AL2023 AMI (the one spawn launch already auto-detects). Something like:
process {
withName: 'KRAKEN2_KRAKEN2' {
ext.instanceType = 'r7g.2xlarge'
ext.volumes = [[ snapshot: 'snap-0abc...', mount: '/opt/databases/kraken2', readOnly: true ]]
// ext.ami can then be omitted → stock AL2023
}
}This would let:
- the DB volume be sized for the DB (~20 GB), created once from a snapshot and mounted read-only by every Kraken2 task;
- the spore root volumes shrink to per-task size (OS + container + scratch) instead of all carrying the baked DB;
- the base image stay the stock AL2023 spawn auto-detects — no custom-AMI maintenance, no per-arch bake;
- DB updates be a re-snapshot, not an AMI rebuild.
The two-layer dependency
This needs support in both projects, which is why I'm filing here (the consumer-facing ext) and noting the spawn-side piece:
- spawn (
spore-host/spawn):spawn launchtoday exposes--volume-size(root size only),--efs-id, and--fsx-id/--fsx-create— but no flag to attach an EBS volume from a snapshot (block-device-mapping). That primitive is needed first (e.g.--attach-volume snap-xxx:/mount:ro). - nf-spawn:
SpawnTaskHandler.submit()currently forwards onlyext.instanceType / region / ttl / spot / ami / volumeSize. It would need anext.volumes(or similar) that maps to the new spawn flag.
Alternatives considered
- EFS / FSx-Lustre — spawn already has
--efs-id/--fsx-id/--fsx-create, but nf-spawn forwards neither today. FSx-Lustre with S3 backing would suit read-heavy shared references; anextto forward--fsx-id/--efs-idwould be a lighter first step than EBS-snapshot attach, if that's preferable. Either solves the "don't bake data into the AMI" goal. - Per-task S3 fetch in the task script (what FETCH_FASTQ does for RODA) — works with zero plugin changes but pays the ~12 GB DB pull on every cold Kraken2 task; not viable for wide fan-out.
Context
Found while getting taxprofiler to run end-to-end on Graviton (the #37→#43 series). Not blocking that work — the baked AMI functions — but it's the right factoring for repeated large-reference workloads. Full tradeoff analysis lives in the demo repo at docs/ami-vs-data-volume.md. Happy to test an implementation against the taxprofiler demo.
Activity
scttfrdmn commentedon Jun 13, 2026
You're right that this is a two-layer feature, and confirmed: the spawn-side primitive doesn't exist yet and has to land first. I dug through spawn to verify before filing:
cmd/launch.goexposes--volume-size(root only),--efs-id,--fsx-id/--fsx-create— no flag to attach an EBS volume from a snapshot.pkg/aws/client.gobuildBlockDevicesemits exactly one block-device mapping (the root/dev/xvda); there's no path for an additionalEbs.SnapshotIddevice.pkg/userdata/storage.gohas mount templates for FSx and EFS but nothing for an attached EBS volume.So nf-spawn#45 is blocked on spawn until that primitive exists. Filed it: spore-host/spawn#144 —
--attach-volume snap-xxx:/mount:ro(block-device-mapping + NVMe-aware RO mount in user-data +DeleteOnTerminationso the per-task copy dies with the instance).Sequencing:
--attach-volume(the block-device primitive). (blocks this)ext.volumes = [[snapshot:…, mount:…, readOnly:true]], resolve it inSpawnTaskHandler.submit()(which today forwards onlyinstanceType/region/ttl/spot/ami/volumeSize), and map it to--attach-volume. Stock AL2023, no custom AMI.I went with EBS-snapshot attach over forwarding
--efs-id/--fsx-idbecause a created-once, read-only reference blob mounted as local block storage matches your Kraken2 DB use case best — but I noted the FSx/EFS-forwarding alternative in #144 as the lighter path if you'd rather start there. Keeping this open as the consumer-side tracker; I'll wire it up once #144 ships. Will take you up on validating against the taxprofiler demo.feat: ext.volumes attaches EBS data volumes from snapshots (#45) (#46)
scttfrdmn commentedon Jun 13, 2026
Two AWS capabilities make this materially better than a naive snapshot, and they split across the build and read sides:
Build side — no bake instance needed. The EBS direct APIs (
StartSnapshot→PutSnapshotBlock×N →CompleteSnapshot, plusListChangedBlocksfor incremental) let you populate a snapshot directly from an S3 object / local dir with no EC2 instance attached. So building the Kraken2 DB snapshot drops the whole launch→download→extract→spawn ami create→terminate dance, and a DB update only writes changed blocks instead of a fresh 16 GB.Read side — Fast Snapshot Restore. A volume created from a snapshot lazy-loads blocks from S3 on first access, so a 100-way fan-out all creating volumes from the same snapshot would each eat first-read latency. FSR pre-warms the snapshot so every volume-from-it is immediately at full performance — that's the ingredient that makes the data-volume path match baked-AMI cold-start speed for wide fan-out (per-AZ hourly cost while enabled; enable during a run, disable after).
So the
ext.volumesask here is still exactly right for the attach/read side; the direct APIs just make the build side instance-free and FSR fixes the cold-volume performance. I've filed the spawn-side primitive (build-snapshot + attach-FSR-warmed-volume) separately onspore-host/spawnand cross-referenced it. Full write-up in the demo repo'sdocs/ami-vs-data-volume.md.scttfrdmn commentedon Jun 13, 2026
Confirming the split your follow-up laid out, now that both sides have shipped:
ext.volumesis released in nf-spawn v0.3.0 —[[ snapshot:, mount:, readOnly: ]]maps tospawn launch --attach-volume snap-xxx:/mount[:ro|:rw]. Requires spawn ≥ 0.46.0.spawn snapshot create --from <raw-image> --size Nbuilds a snapshot with no bake instance (released in spawn v0.47.0). So the full path is now:spawn snapshot create→ext.volumesin your config → attached read-only on a stock AMI.No nf-spawn change needed for the FSR/build work — it's all under the
--attach-volumeyourext.volumesalready targets. When you're ready to validate end-to-end on the taxprofiler Kraken2 step (realk2_pluspfsnapshot, stock arm64 AMI, leak-checked), I'll pair on it — that doubles as the live test for spawn#144/#147. Bump to nf-spawn 0.3.0 + spawn 0.47.0 to try it.feat: per-task setup hook so stock AL2023 works (#47) (#48)