Sign Up

Preemption

Discounted spot sandboxes that Daytona can reclaim when it needs capacity.

Daytona sandboxes run on reserved capacity by default: once placed, a sandbox keeps its resources until you stop, pause, or delete it. A spot sandbox is preemptible: it is billed at a discount, and Daytona can reclaim it at any time to free capacity for full-price sandboxes. The tier is set when the sandbox is created and cannot be changed afterwards.

What a reclaim does depends on whether the sandbox is persistent. An ephemeral spot sandbox is deleted; a persistent one keeps its state and can be brought back.

Sandbox typeOn reclaimRecovery
Ephemeral
(default)
Deleted, with its filesystemCreate a new sandbox; keep results on a volume
Persistent
(Linux)
Paused, with filesystem, memory, and processes keptResume continues processes from the point they were frozen
Persistent
(Linux)
Stopped, with the filesystem kept and memory clearedStart boots the sandbox from its filesystem
Persistent
(Windows)
Stopped, with the disk keptStart boots Windows from the preserved disk

Use cases

Spot sandboxes are used for work that tolerates an interruption in exchange for a lower price.

  • Batch jobs: data processing, builds, and test runs on ephemeral sandboxes start again from the beginning when a sandbox is reclaimed. Spot multiplies the CPU, memory, and disk price by 0.7.
  • Evaluation and reinforcement learning (RL): many short test cases or episodes run on spot sandboxes. A reclaimed test case or episode runs again in a new sandbox.
  • CI runs: build and test jobs run on Linux or Windows spot sandboxes. A reclaim costs one rerun of the job.
  • Stateless workers: workers that keep no state in the sandbox lose nothing on a reclaim. A new spot sandbox replaces the reclaimed one.
  • Results on volumes: an ephemeral spot sandbox writes its output to a volume, so a reclaim loses only the work in progress.
  • Long jobs on persistent sandboxes: a persistent spot sandbox keeps its filesystem on reclaim and continues after a resume or a start. A persistent Linux sandbox without an attached volume also keeps its memory and running processes.
  • Development and experiments: sandboxes whose loss costs only a restart run at the spot price.

Spot sandboxes

A spot sandbox differs from an on-demand sandbox only in price and reclaim. In every other respect it is an ordinary sandbox: it supports the same images, resources, volumes, and lifecycle operations as an on-demand sandbox of its type. Spot multiplies the CPU, memory, and disk price by 0.7; see pricing dimensions.

Linux and Windows sandboxes can be spot. GPU sandboxes cannot.

from daytona import Daytona

daytona = Daytona()

# A persistent spot sandbox is paused on reclaim instead of deleted
sandbox = daytona.v2.create(
    spot=True,
    persistent=True,
)
ParameterTypeDescription
spotboolPlaces the sandbox on discounted, reclaimable capacity. The default is False. The value is fixed at create.

Reclaim policy

Daytona tracks the CPU, memory, and disk reserved on each host. When the reservation on a host crosses a threshold on any of the three, Daytona reclaims running spot sandboxes on that host until the projected reservation drops below it. Newer spot sandboxes are reclaimed before older ones, interrupting the least accumulated work first. On-demand sandboxes are never reclaimed, and spot sandboxes that are already paused or stopped are not touched.

A reclaim is immediate. Daytona does not notify the sandbox or your application in advance, and there is no grace period. Daytona does not bring a reclaimed sandbox back on its own when capacity frees up: resuming or starting it again is up to you.

A reclaimed sandbox is billed like any paused, stopped, or deleted sandbox.

Reclaim outcomes

Daytona records the reclaim time, then tears the sandbox down like a user request:

SandboxOutcome
EphemeralMoves to deleting, then deleted; only data on a volume remains.
Persistent LinuxThe sandbox moves to pausing and then paused, with filesystem, memory, and running processes preserved. See pause / resume.
Persistent Linux with an attached volumeIt cannot pause, so it moves to stopping, then stopped; the filesystem is kept, memory cleared. See stop / start.
Persistent WindowsStopped, since Windows cannot pause. See stop / start.

For the full state model, see lifecycle.

Reclaim detection

Reclaim detection tells a reclaim apart from a stop, pause, or delete you requested. Every reclaimed sandbox carries the time of the reclaim, which is cleared when the sandbox is started or resumed again. A sandbox that was never reclaimed, or has been brought back since, carries no reclaim time.

from daytona import Daytona

daytona = Daytona()
sandbox = daytona.v2.get("{sandboxId}")

# None unless the platform reclaimed this spot sandbox
if sandbox.spot_evicted_at:
    print(f"reclaimed at {sandbox.spot_evicted_at}, state: {sandbox.state}")

# Find spot sandboxes that are paused or stopped
page = daytona.v2.search(spot=True, status=["paused", "stopped"])
for sandbox in page.items:
    print(sandbox.id, sandbox.state, sandbox.spot_evicted_at)
ParameterTypeDescription
spotboolFilters by capacity type. True returns only spot sandboxes, and False returns only on-demand sandboxes. The default is None, which returns both.

Reclaim recovery

Reclaim recovery depends on the sandbox type. A persistent sandbox comes back with its ID and state. An ephemeral one is gone; continue in a new sandbox from volume data.

from daytona import Daytona

daytona = Daytona()
sandbox = daytona.v2.get("{sandboxId}")

# start resumes a paused sandbox or starts a stopped one, then waits until it runs
if sandbox.spot_evicted_at:
    sandbox.start()
ParameterTypeDescription
timeoutfloatSets how many seconds start() waits for the sandbox to run. The default is 60.

Opting in to preemption

Spot suits work that tolerates interruption and can be restarted or continued: batch jobs, evaluation and reinforcement learning rollouts, CI runs, and stateless workers. Keep spot off sandboxes that serve live traffic or hold state that exists nowhere else.

  • Make spot sandboxes persistent when the work is worth continuing: a reclaim then pauses or stops the sandbox instead of deleting it. See persistence.
  • Checkpoint to a volume from ephemeral spot sandboxes, so a replacement sandbox can continue where the reclaimed one stopped. See volumes.
  • Check after interruptions: when a sandbox stops responding or changes state unexpectedly, read its reclaim time to tell a reclaim apart from a failure.