Skip to content

Feature: attach a pre-populated EBS data volume per process (e.g. ext.volumes / snapshot mount) so large reference data isn't baked into the AMI #45

Closed

Description

@scttfrdmn

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:

  1. spawn (spore-host/spawn): spawn launch today 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).
  2. nf-spawn: SpawnTaskHandler.submit() currently forwards only ext.instanceType / region / ttl / spot / ami / volumeSize. It would need an ext.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; an ext to forward --fsx-id/--efs-id would 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

  1. added
    enhancement
    on Jun 13, 2026
  2. scttfrdmn commented on Jun 13, 2026

    @scttfrdmn
    CollaboratorAuthor

    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.go exposes --volume-size (root only), --efs-id, --fsx-id/--fsx-create — no flag to attach an EBS volume from a snapshot.
    • pkg/aws/client.go buildBlockDevices emits exactly one block-device mapping (the root /dev/xvda); there's no path for an additional Ebs.SnapshotId device.
    • pkg/userdata/storage.go has 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 + DeleteOnTermination so the per-task copy dies with the instance).

    Sequencing:

    1. spawn#144 — add --attach-volume (the block-device primitive). (blocks this)
    2. nf-spawn#45 (this issue) — add ext.volumes = [[snapshot:…, mount:…, readOnly:true]], resolve it in SpawnTaskHandler.submit() (which today forwards only instanceType/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-id because 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.

  3. scttfrdmn commented on Jun 13, 2026

    @scttfrdmn
    CollaboratorAuthor

    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, plus ListChangedBlocks for 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.volumes ask 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 on spore-host/spawn and cross-referenced it. Full write-up in the demo repo's docs/ami-vs-data-volume.md.

  4. scttfrdmn commented on Jun 13, 2026

    @scttfrdmn
    CollaboratorAuthor

    Confirming the split your follow-up laid out, now that both sides have shipped:

    • Attach/read side (this issue): done. ext.volumes is released in nf-spawn v0.3.0 — [[ snapshot:, mount:, readOnly: ]] maps to spawn launch --attach-volume snap-xxx:/mount[:ro|:rw]. Requires spawn ≥ 0.46.0.
    • Spawn build side: done (Part A). Filed your EBS-direct-API + FSR write-up as Feature: build a reference-data EBS snapshot via EBS direct APIs + attach FSR-warmed volumes — get large reference data onto spores without baking AMIs spawn#147 and implemented Part A — spawn snapshot create --from <raw-image> --size N builds a snapshot with no bake instance (released in spawn v0.47.0). So the full path is now: spawn snapshot create → ext.volumes in your config → attached read-only on a stock AMI.
    • FSR + directory/tarball→filesystem-image builder are Part B on spawn#147 (FSR bills per-AZ-hour, so it'll be explicit opt-in with a cost confirmation — planned, not silently auto-enabled).

    No nf-spawn change needed for the FSR/build work — it's all under the --attach-volume your ext.volumes already targets. When you're ready to validate end-to-end on the taxprofiler Kraken2 step (real k2_pluspf snapshot, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions