Skip to content

Waiting for scarce capacity โ€‹

A complete walkthrough for the case where the instance you want isn't available right now โ€” a scarce GPU family like p5.48xlarge. Instead of re-running a launch by hand, you'll set Lagotto to watch for capacity and act the moment it appears. Allow about 15 minutes.

What you'll accomplish โ€‹

  • A Lagotto watcher deployed in your own AWS account
  • A watch that checks three regions every five minutes
  • A notification the moment capacity is found โ€” with no automatic launch
  • Then: the same watch upgraded to launch automatically with a TTL

Prerequisites โ€‹

  • truffle and spawn installed and working and AWS credentials verified
  • lagotto installed: brew install spore-host/tap/lagotto
  • Confirm you're actually allowed to launch the type you want before you wait for it โ€” see the four questions below

First, know which question you're answering โ€‹

Capacity is the last of four different questions, and only Lagotto answers it. Don't skip the first three โ€” waiting for capacity you have no quota for is wasted time:

QuestionAnswered by
Does this EC2 type exist in this region?Truffle โ€” truffle find / truffle az
Am I allowed to launch it under my quota?Truffle โ€” truffle quotas
Can AWS actually place one right now?Spawn launch attempt / Lagotto
Should I keep checking until placement succeeds?Lagotto
sh
truffle quotas --regions us-east-1,us-west-2,us-east-2 --family P

If quota is zero, request an increase first โ€” Lagotto can't launch what your quota forbids (that's a terminal failure, not a capacity wait).


1. Deploy the watcher โ€‹

Lagotto runs as a serverless poller in your own account. Stand it up once:

sh
lagotto deploy

This deploys a Lambda + EventBridge schedule + DynamoDB + IAM via CloudFormation. The schedule deploys disabled โ€” your first watch arms it, and it tears itself down when no watches remain.


2. Create a notify-only watch โ€‹

Start conservatively: watch three regions, check every five minutes, and just tell me when capacity appears โ€” don't launch anything yet.

sh
lagotto watch "p5.48xlarge" \
  --regions us-east-1,us-west-2,us-east-2 \
  --action notify \
  --notify email:you@example.com \
  --ttl 7d
  • --action notify โ€” alert only; nothing launches
  • --ttl 7d โ€” give up after a week if capacity never appears (the TTL is the only time limit; there's no max-retry count)

Confirm it's active:

sh
lagotto list
lagotto status <watch-id>

Lagotto now polls every ~5 minutes. When it finds capacity, you get an email and the watch is marked matched.


3. Upgrade it to launch automatically โ€‹

Once you trust the watch, replace "notify me" with "launch it for me." Write a spawn config describing the instance you want, with a TTL so the launched instance still self-terminates:

yaml
# gpu-job.yaml
name: training
instance_type: p5.48xlarge
ttl: 6h
on_complete: terminate
command: ./run-training.sh && spored complete --status success

Then create the auto-launch watch:

sh
lagotto watch "p5.48xlarge" \
  --regions us-east-1,us-west-2,us-east-2 \
  --action spawn \
  --spawn-config gpu-job.yaml \
  --notify email:you@example.com \
  --ttl 7d

Now when capacity appears, Lagotto launches the instance with a 6-hour TTL, runs your job, and the instance terminates on completion โ€” the whole chain fires with no one awake to run it.

The launch attempt is the capacity test

There's no AWS API that reports "capacity is available now." For a spawn watch, Lagotto's launch attempt is the real test: if AWS returns InsufficientInstanceCapacity the watch stays active and retries next poll. A terminal error (bad AMI, exhausted quota) marks the watch failed instead of retrying forever.


4. Clean up โ€‹

A watch ends on its own when it matches, fails, or its TTL expires. To stop one early:

sh
lagotto cancel <watch-id>

When no watches remain, the poller disables its own schedule automatically. To remove the whole stack:

sh
lagotto deploy --teardown

What just happened โ€‹

You turned "keep manually re-trying a launch for a scarce GPU" into a fire-and-forget watch running in your own account. Lagotto did the tedious retrying, respected your quota, and โ€” in the auto-launch version โ€” handed off to spawn, which launched an instance that manages its own lifecycle via spored.

Next steps โ€‹

  • Lagotto โ€” every action, SageMaker watches, and Capacity Blocks for ML
  • Scheduled launches โ€” launch by clock time (e.g. into a Capacity Block)
  • GPU Training Jobs โ€” what to run once you have the instance