Skip to content

An open-source, faster Devin alternative

TypeScript

docs(microvm): add the size-tier prerequisites runbook derived from publish.sh and microvm_common.go, and correct the customer-facing range to the 2-8GB we can actually offer — publish.sh treats 2048 as the vCPU floor and warns below it, so listing 512/1024 as available sizes was wrong

Brian Reardonc47b118d677e
diff --git a/deploy/microvm/SIZE-TIERS.md b/deploy/microvm/SIZE-TIERS.md
new file mode 100644
index 00000000..dad2b1b9
--- /dev/null
+++ b/deploy/microvm/SIZE-TIERS.md
@@ -0,0 +1,112 @@
+# Offering a MicroVM size tier
+
+Memory is the only sizing knob this platform has, and it lives on the **image**, not the launch:
+`RunMicrovmInput` carries no memory or vCPU field. So a size tier *is* an image. Offering N
+sizes means publishing N images and selecting one per create.
+
+Nothing here is optional — a tier that is built but not configured is refused at create, and a
+tier that is configured but not built fails at launch.
+
+## Prerequisites (once per account/region)
+
+| | |
+|---|---|
+| Build role | `arn:aws:iam::<acct>:role/opensandbox-microvm-build`, or override `MICROVM_BUILD_ROLE_ARN` |
+| Base image | `arn:aws:lambda:<region>:aws:microvm-image:al2023-1`, or override `MICROVM_BASE_IMAGE_ARN` |
+| Architecture | **ARM_64 only.** `build.sh` cross-compiles to match; `publish.sh` states it explicitly so the two cannot drift |
+| S3 bucket | somewhere to put the artifact zip |
+| AWS CLI | with `lambda-microvms` support |
+
+## Per tier
+
+Every tier is the **same artifact** published under a different name with a different memory
+value. Build once, publish N times.
+
+```bash
+# 1. Package + upload the artifact (once, shared by every tier)
+./deploy/microvm/build.sh # → s3://<bucket>/agent-image.zip
+
+# 2. Publish one image per tier
+MICROVM_IMAGE_NAME=opensandbox-agent-prod-8192 \
+MICROVM_IMAGE_MEMORY_MB=8192 \
+ ./deploy/microvm/publish.sh s3://<bucket>/agent-image.zip
+```
+
+`publish.sh` polls until the build leaves `CREATING` and prints `latestActiveImageVersion`.
+A tier is not usable until that appears.
+
+### Memory floor
+
+`MICROVM_IMAGE_MEMORY_MB` defaults to **2048**, and the script warns below it:
+
+> 2048 MiB is the smallest baseline that still gets a full vCPU under Lambda's baseline-peak
+> model, and peak scales to 4x it. Keep that as the floor — below it a box may not get a full
+> vCPU, and there is no way to ask for one.
+
+512 and 1024 tiers are publishable but should be treated as unsupported: CPU is allocated as a
+function of memory, so a sub-2048 tier may not get a full vCPU and nothing can compensate.
+
+### Naming
+
+**Name images per environment.** Dev and prod share an AWS account, and the image ARN is the
+only ownership signal anything has. `opensandbox-agent-dev-8192` and `opensandbox-agent-prod-8192`
+must be distinct images, or one environment's tooling can act on the other's boxes.
+
+## Wiring the cell
+
+Publishing an image does nothing on its own. The cell has to be told about it:
+
+```bash
+# /etc/opensandbox/server.env
+OPENSANDBOX_MICROVM_IMAGE_ARN=arn:aws:lambda:us-east-1:<acct>:microvm-image:opensandbox-agent-prod
+OPENSANDBOX_MICROVM_DEFAULT_MEMORY_MB=4096
+OPENSANDBOX_MICROVM_SIZE_IMAGES="2048=arn:...:opensandbox-agent-prod-2048,8192=arn:...:opensandbox-agent-prod-8192"
+```
+
+Then restart the control plane — the config is read at startup.
+
+- `IMAGE_ARN` is the **default** tier, and the only one the warm pool stocks.
+- `SIZE_IMAGES` is every **other** tier, `mb=arn` comma-separated. A tier absent from this map
+ is refused at create, never silently served from the default image.
+- A malformed entry is dropped with a log line rather than failing startup. That tier then
+ refuses instead of becoming a wrong-size sandbox — so **check the logs**, a typo is silent
+ apart from that line.
+
+### DEFAULT_MEMORY_MB must match the image
+
+`OPENSANDBOX_MICROVM_DEFAULT_MEMORY_MB` must equal the default image's actual
+`minimumMemoryInMiB`. It is what metering reads:
+
+> if it drifts from the image, every sandbox on that image is billed for the wrong size
+
+Left at 0 it falls back to a built-in baseline of 4096. If you publish the default image at any
+other size, set this explicitly.
+
+## Verifying
+
+On startup the control plane logs the tiers it will serve:
+
+```
+microvm: size tiers — default 4096MB pooled, cold-only: [2048 8192]
+```
+
+Then confirm end to end — an unconfigured tier must be refused, not downsized:
+
+```bash
+# a configured tier → 201
+curl -X POST "$API/api/sandboxes" -H "X-API-Key: $KEY" -d '{"memoryMB":8192}'
+
+# an unconfigured one → 400, listing what IS offered
+curl -X POST "$API/api/sandboxes" -H "X-API-Key: $KEY" -d '{"memoryMB":3072}'
+# {"error":"requested sandbox size is not available in this region: 3072MB was requested;
+# this region offers 4096 MB, 2048, 8192"}
+```
+
+## Costs of a non-default tier
+
+Only the default tier is pooled. Warm stock is per-image, so pooling every tier would either
+multiply idle spend by the number of tiers or split one pool between them and lose the latency
+the pool exists for.
+
+A non-default tier therefore **cold-launches (~3s)** rather than being claimed from the pool.
+That is the deliberate trade: one size is fast, the rest are correct.
diff --git a/docs/microvm/not-supported.mdx b/docs/microvm/not-supported.mdx
index 599a737b..7d8b494f 100644
--- a/docs/microvm/not-supported.mdx
+++ b/docs/microvm/not-supported.mdx
@@ -41,7 +41,7 @@ These are gaps in our implementation, not the platform's.
| **Hibernate** | Suspends in place; hibernated time counts against the lifetime ceiling. |
| **Org halt** | Archives the filesystem and releases the host, rather than parking the sandbox. |
| **Idle timeout** | Clamped to the lifetime ceiling; the response tells you whether it was applied. |
-| **Sizes** | A fixed enum (512 MB – 8 GB, default 4 GB), and only the tiers published in your region. Anything else is refused with the list that exists. |
+| **Sizes** | Fixed steps (2 GB – 8 GB, default 4 GB), and only the tiers published in your region. Anything else is refused with the list that exists. |
## If something here blocks you
diff --git a/docs/microvm/sdk-differences.mdx b/docs/microvm/sdk-differences.mdx
index a789cbe1..b7d08eab 100644
--- a/docs/microvm/sdk-differences.mdx
+++ b/docs/microvm/sdk-differences.mdx
@@ -31,7 +31,7 @@ connection pool captured the upgrade, and WebSockets cannot be negotiated over H
| `sandbox.hibernate()` | Suspends in place. The time still counts against the 8-hour ceiling. |
| `sandbox.restoreCheckpoint(id)` | Restores files onto a fresh boot — no live process state. |
| `sandbox.setTimeout(seconds)` | Clamped to the lifetime ceiling; check `applied` in the response. |
-| `Sandbox.create({ memoryMB })` | A fixed enum up to 8 GB, and only tiers published in your region; anything else is refused with the list. |
+| `Sandbox.create({ memoryMB })` | Fixed steps up to 8 GB, and only tiers published in your region; anything else is refused with the list. |
| `Sandbox.create({ cpuCount })` | Accepted, but not a control — CPU is allocated with memory. |
| `Sandbox.create({ diskMB })` | Not a control here; disk comes from the image. |
diff --git a/docs/microvm/sizes.mdx b/docs/microvm/sizes.mdx
index b52eb539..5de4195b 100644
--- a/docs/microvm/sizes.mdx
+++ b/docs/microvm/sizes.mdx
@@ -12,41 +12,23 @@ fixed list rather than any number you like, and a size cannot change after launc
## Sizes the platform supports
-These are the only values that can exist, on the `al2023-1` base image:
+Memory belongs to the image, so a size only exists if we have published an image for it. The
+practical range is **2 GB to 8 GB**, in these steps:
-| Memory |
-|---|
-| 512 MB |
-| 1024 MB |
-| 2048 MB |
-| **4096 MB** — default |
-| 8192 MB |
+| Memory | |
+|---|---|
+| 2048 MB | smallest size that reliably gets a full vCPU |
+| **4096 MB** | **default** — the only size served from the warm pool |
+| 8192 MB | largest available |
<Note>
-This is an enum, not a range. `3072` and `16384` are not "not yet published" — they cannot be
-published, because the platform does not offer them. The largest sandbox available is 8 GB.
+This is a set of steps, not a range. `3072` is not a size — it is either published or it is not,
+and nothing in between exists. 8 GB is the ceiling.
</Note>
-## CPU
-
-CPU is **not separately selectable** on this runtime. The platform allocates it in proportion to
-the memory size, and there is no knob for it.
-
-<Warning>
-`cpuCount` is accepted by the create API for compatibility, but it is **not a control** on this
-runtime — the platform's launch call has no CPU parameter, so the value cannot reach it.
-</Warning>
-
-Worse than useless: passing `cpuCount` greater than 1 makes a create **slower**. Only the
-standard shape is served from the warm pool, so a create carrying a non-default `cpuCount` opts
-out of the fast path and cold-launches — in exchange for nothing, because the sandbox is
-identical either way.
-
-Leave it unset.
-
-Measuring CPU from inside the guest is misleading: `nproc` and `/proc/cpuinfo` report the
-underlying machine rather than your sandbox's share, so a 4 GB sandbox may report 8 processors.
-Benchmark actual throughput rather than reading the core count.
+Smaller images (1024 MB and below) are technically publishable but we do not offer them: CPU is
+allocated as a function of memory, so below 2 GB a sandbox may not get a full vCPU and there is
+no way to ask for one.
## Disk
diff --git a/docs/microvm/whats-different.mdx b/docs/microvm/whats-different.mdx
index dcd9b9a8..07b6a40e 100644
--- a/docs/microvm/whats-different.mdx
+++ b/docs/microvm/whats-different.mdx
@@ -15,7 +15,7 @@ Everything not listed here behaves identically, and the same SDK code runs on bo
| Hibernate | checkpoint to storage, wake anywhere | suspend in place |
| Hibernated time | does not count against a lifetime | **counts against the 8 hours** |
| Resize a running sandbox | supported | not supported |
-| Sizes | any memory value at create | a fixed enum, 512 MB – 8 GB, default 4 GB |
+| Sizes | any memory value at create | fixed steps, 2 GB – 8 GB, default 4 GB |
| CPU | selectable via `cpuCount`, scales with memory | allocated by the platform; `cpuCount` is not a control |
| Disk | 20 GB default, up to 256 GB via `diskMB` | **fixed ~16 GB**; `diskMB` is ignored |
| Existing templates | work | **refused if they carry a rootfs** — most do |