Skip to content

--cost-limit on Spot instances is enforced at the on-demand rate, and terminates the job without a signal #1497

Description

@scttfrdmn

spawn 0.152.0. spawn launch --spot --cost-limit 7 --ttl 5h ... on c9gd.16xlarge (us-east-1, Spot $1.09/h at launch, on-demand $3.418/h). spored terminated the instance after 2.05 h, i.e. when on-demand rate × compute time reached $7.01. Actual Spot spend was about $2.23. spawn cost --help confirms the estimate is "the on-demand rate (spawn:price-per-hour tag) × its compute time".

Two problems:

  1. A Spot cost limit is ~3× tighter than the user's budget, with nothing at launch saying so. Users naturally size the limit at the Spot price they see.
  2. The job gets no warning. The instance terminated 5 s after the job's last log sync, mid-step: no SIGTERM to the --command process, no grace period, no final log/result upload. A long batch job loses its work and its evidence.

Suggestions:

  • For Spot instances, track spend from Spot price history (or the price at launch), or at least state at launch: "cost limit is enforced at the on-demand rate $X/h → effective runtime Y h".
  • On reaching the limit, signal the command (SIGTERM), wait a grace period (configurable, e.g. 2 min), then terminate. Tag the instance with the reason (spawn:terminated-by=cost-limit) so spawn list and CloudTrail show why.
  • spawn extend --raise-cost-limit is the right escape hatch; mention it in the launch output when the limit < TTL × on-demand rate.

Activity

  1. added this to the Hardening milestone on Nov 8, 2026
  2. scttfrdmn commented on Nov 8, 2026

    @scttfrdmn
    ContributorAuthor

    PR #1555 fixes the first half: Spot compute is now counted at the Spot price spored samples, with a labelled on-demand fallback. It needs a live EC2 check before merge, and the plan is in the PR. The second half (no SIGTERM or grace period at the limit, and a terminated-by tag) is split out to #1554, because #1555's Fixes #1497 will close this issue.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions