Skip to content

Disks

A disk is a POSIX filesystem stored in object storage. The data clients are using sits in Archil’s storage layer, in front of the bucket, so reads and writes run at disk speed while the bucket holds everything. A write is durable once fsync returns. The bucket is Archil’s, or your own.

One disk is reachable three ways at once: mounted as a filesystem, through serverless exec, and as an S3-style bucket of objects.

DatasetsyncsApimountexecmicroVM per callWorkerReadDisk · S3 APIstorage layerdata in usebucketevery file
Mounts, exec calls and S3 requests all reach the same disk and see each other's writes. Archil keeps the data in use in front of the bucket and copies writes to the bucket in the background.

Create a disk for each user or session at run time, and declare the few shared ones in your Stack.

Archil.CreateDisk gives a Worker or Lambda a client that creates disks by name:

const disks = yield* Archil.CreateDisk();
const home = yield* disks.create(`user-${user}`);

Calling create again with the same name returns the same disk. get, list, and delete work on the disks this client created.

A dataset every user reads is a resource:

src/Storage.ts
export const Dataset = Archil.Disk("Dataset", {});

Restrict where it can be mounted from with allowedIps, and stop sandboxes and exec from mounting it with allowSandboxMount: false.

const dataset = yield* Archil.ExecDisk(Dataset);
const result = yield* dataset.exec("wc -l /mnt/archil/*.csv");
const hits = yield* dataset.grep({ pattern: "TODO", directory: "src", recursive: true });

ExecDisks mounts several disks in one call, at paths under /mnt/archil.

Every disk is also an S3-style bucket. ReadDisk, WriteDisk, and ReadWriteDisk use it:

const files = yield* Archil.ReadWriteDisk(Dataset);
yield* files.put("notes/today.md", "# Today");
const url = yield* files.share("notes/today.md", 3600);

A write that conflicts with a mounted client’s lock fails with ObjectConflict.

Copy a disk per session from a checkpoint with Branches and checkpoints. Keep a disk’s files as ordinary objects in your S3 bucket with Your own bucket.