Skip to content

Forward ext.az to spawn launch --az (pin task placement to an AZ) #62

Closed

Description

@scttfrdmn

Problem

A Nextflow task that needs a volume from an FSR-warmed snapshot has no way to land in the AZ where Fast Snapshot Restore is enabled. FSR is per-AZ; a volume created from the snapshot in a different AZ is NOT fast-restored and lazy-loads every first-touch block from S3 at ~6-8 MB/s. For a 16 GB Kraken2 DB that's ~40 min of pure DB-load before the tool classifies a single read; a 40 GB MetaPhlAn index is worse.

SpawnTaskHandler reads ext.instanceType/region/ttl/spot/ami/volumeSize/volumes but not ext.az. And spawn launch leaves SubnetId unset when none is passed (EC2 picks placement), with no subnet/az default in ~/.spawn/config.yaml. So there is no in-band way to pin a task to the FSR AZ.

Observed: across two real runs, tasks landed in us-east-1a once and us-east-1c the next — pure EC2 placement luck. FSR enabled in 1a was wasted on the 1c run.

Proposal

Forward a new ext.az directive to spawn launch --az <zone> (spawn already has the flag). Pass it only when set, so the default preserves spawn's own placement.

process {
  withName: 'KRAKEN2_KRAKEN2' {
    ext.az = 'us-east-1a'   // pin to the AZ where the DB snapshot's FSR is enabled
    ext.volumes = [[ snapshot: 'snap-...', mount: '/opt/databases/kraken2', readOnly: true ]]
  }
}

Implementation

Done locally in 0.6.1: read ext.az in submit(), add an optional az param to buildLaunchCommand that appends --az <zone> when non-empty. Test added (passes --az only when set; back-compat default otherwise). 55 specs green. Happy to open a PR.

Activity

  1. scttfrdmn commented on Jun 15, 2026

    @scttfrdmn
    CollaboratorAuthor

    To be clear: this is a feature request, not a fork to merge — I'm not modifying nf-spawn. The implementation sketch above is just to show it's a small change; please implement it however fits the codebase. The consuming project (aws-microbiome-demo) stays on released nf-spawn 0.6.0 and has a no-op seam ready to enable ext.az once a release ships.

  2. scttfrdmn commented on Jun 15, 2026

    @scttfrdmn
    CollaboratorAuthor

    Shipped in nf-spawn v0.7.0 — https://github.com/spore-host/nf-spawn/releases/tag/v0.7.0 (plugin asset nf-spawn-0.7.0.zip).

    ext.az is implemented as you sketched: read in submit(), appended to spawn launch as --az <zone> only when set (unset preserves spawn's own placement). aws-microbiome-demo can now bump to 0.7.0 and flip the ext.az seam — set it to the AZ where the snapshot's FSR is enabled:

    process {
      withName: 'KRAKEN2_KRAKEN2' {
        ext.az = 'us-east-1a'
        ext.volumes = [[ snapshot: 'snap-...', mount: '/opt/databases/kraken2', readOnly: true ]]
      }
    }

    README directive table documents it. Thanks for the clear write-up + the no-op seam — made this a clean drop-in.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions