SDK
Persistence

Persistence

Sandboxes have three states of persistence:

  • Memory: The sandbox has a memory snapshot and will be restored from memory when started. This takes 1-2 seconds.
  • Disk: The sandbox has a disk snapshot, but needs to boot from scratch. This takes 5-20 seconds.
  • Archived: The sandbox has no disk, and will be recreated from our archive storage. This takes 20-60 seconds.

If dormant, a sandbox will retain a memory snapshot for 7 days, a disk snapshot for 2 weeks, and an archive for undetermined time (so far in the last 4 years, we've never deleted an archive).

Memory

Whenever a sandbox is hibernated, we keep a memory snapshot of the underlying Firecracker VM. When you start that sandbox, or if any network request is made to the sandbox. We restore the memory snapshot and you can continue from where you left off (this takes 0.5-2 seconds).

Memory snapshots are kept for a week (this can be longer depending on your plan, and disk pressure). Afterwards, they'll be deleted. If the sandbox is used (either resumed or forked), the timer will reset and the memory snapshot will be kept.

Disk

Sandboxes have two layers of disk persistence:

  • /persisted: contains our archive of the sandbox. If you start a sandbox after a year of inactivity, the /persisted directory will still be there. Because of this, it's smaller than the /project/sandbox directory.
💡

We keep a .git directory in /persisted to track the filesystem of the sandbox, which we regularly commit to.

  • /project/sandbox: this is the working directory of the sandbox. All files saved in this directory will be persisted between reboots. If the sandbox is not started for more than two weeks (or longer, again depending on your plan and disk pressure), we'll commit all files of /project/sandbox to /persisted and delete the disk. If the persisting of those files fails, we won't delete the disk to ensure your data is not lost.