Skip to content

Sandbox Lifecycle Management: Pause, Resume, Snapshot, Hibernation

Aug 30, 20261 min
TL;DRThe business post (order 28) of the Sandbox Series. Sandbox lifecycle management: pause/resume, snapshot/hibernation, resume concepts, implementation, and applicable scenarios for long-running tasks.

Look up & save

Loading dictionary…

🌏 中文版

What This Post Is

This post is the "business" post (order 28) of the Sandbox Series, also serving as the series appendix. It focuses on sandbox lifecycle management:

  1. Pause & Resume — Release compute resources, retain state
  2. Snapshot — Point-in-time state copy, create new sandbox
  3. Hibernation — Long-term idle, zero compute cost state retention
  4. Long-running task scenarios — When lifecycle management is needed
  5. Cost optimization — Reducing costs through lifecycle management

Lifecycle Stages

The complete sandbox lifecycle has six stages:

StageDescriptionResource Usage
CreateStart sandbox from imageFull
ExecuteRun agent codeFull
PauseRelease CPU, retain memory & processMedium (memory)
SnapshotCreate state checkpointLow (storage)
HibernateLong-term idle, zero compute costVery low (storage)
DestroyRelease all resourcesZero
Create → Execute → [Pause ↔ Resume] → [Snapshot → Create from snapshot] → [Hibernate → Wake] → Destroy

Pause & Resume

Concept

Pause temporarily freezes sandbox execution, releases CPU resources, but retains memory and process state. Resume continues execution from the paused state.

Applicable Scenarios

  • Interactive agent workflows: User-agent back-and-forth conversation, sandbox can pause between messages
  • Long tasks waiting for input: Task waiting for external input, sandbox can pause during wait
  • Cost optimization: No CPU charges during idle periods

Implementation Differences

ProviderPause/Resume APIResume SpeedRetained Content
E2Bpause/resume API~1 secondMemory + process + files
Modalpause/resume APIsub-secondMemory + process + files
Vercelpause API3–3 secondsFiles (memory rebuilt)
Cloudflarepause API2–3 secondsFiles (memory rebuilt)
Azure Container Appspause/resume APIDepends on scaleMemory + process + files

Caveats

  • Memory retention cost: Memory still occupies resources during pause; some providers charge by memory size
  • Network disconnection: Network connections drop during pause, need to reconnect after resume
  • External dependency expiration: Tokens, leases, locks may expire during pause

Snapshot

Concept

Snapshot is a point-in-time copy of sandbox state, used for creating new sandboxes, backup, and restore.

Difference from Pause

FeaturePauseSnapshot
Continue executionOriginal sandbox continuesCreate new sandbox
Memory stateRetainedNot retained
Process stateRetainedNot retained
File stateRetainedRetained
Applicable scenarioShort interruptionLong-term storage, cross-sandbox sharing

When to Use

  • Create checkpoints: Create snapshots before important task steps, rollback on failure
  • Cross-sandbox sharing: Copy one sandbox state to multiple new sandboxes
  • Long-term storage: When pause cost is too high, convert to snapshot storage

Hibernation

Concept

Hibernation is a long-term idle state where the complete sandbox state (including memory) is stored to storage media, compute resources fully released, compute cost reduced to near zero.

Applicable Scenarios

  • Long-term idle: Sandbox not used for days or weeks
  • Cost-sensitive: Zero compute cost state retention
  • Periodic workflows: Agent workflows running weekly or monthly

Implementation Differences

ProviderHibernation SupportRetention TimeWake Speed
ModalNoN/AN/A
E2BYesUnlimitedSeconds
BlaxelYes (standby)Unlimited25 ms
Azure Container AppsYesDepends on scaleDepends on scale
FreestyleYesUnlimitedSeconds

Long-Running Task Scenarios

Sandbox lifecycle management is especially suitable for the following long-running task scenarios:

Scenario 1: Multi-step Agent Workflow

Step 1: Analyze data (sandbox executes)
    ↓ Pause
Wait for user confirmation
    ↓ Resume
Step 2: Generate report (sandbox continues executing)

Scenario 2: Parallel Evaluation

Create multiple snapshots from the same baseline state, launch multiple parallel evaluation sandboxes, compare different agent performance.

Scenario 3: Long Training & Evaluation

ML model training or evaluation may take hours or days; sandbox can pause and resume during the process, avoiding restart from scratch after interruption.


Cost Optimization Strategies

StrategyDescriptionApplicable Scenario
Auto-pause on idleSandbox auto-pauses after no activityInteractive agents
Periodic snapshotsPeriodic snapshots of important state, avoid recomputationLong tasks
Hibernate long idleHibernate when not used for long periodPeriodic workflows
Destroy on task completionDestroy sandbox immediately after task completionShort-lived tasks
Choose right billing modelBursty → active-CPU, Long-running → wall-clockAll scenarios

What You Should Understand After Reading

  1. Six sandbox lifecycle stages: create, execute, pause, snapshot, hibernate, destroy.
  2. Difference between pause and snapshot, and applicable scenarios for each.
  3. Hibernation concept and implementation differences (provider support varies).
  4. Three long-running task scenarios: multi-step workflow, parallel evaluation, long training.
  5. Five cost optimization strategies: auto-pause on idle, periodic snapshots, hibernate long idle, destroy on task completion, choose right billing model.

References