| Memory | vCPU |
| 1 GB | 1 (best-effort) |
| 4 GB | 1 |
| 8 GB | 2 |
| 16 GB | 4 |
scale and the in-VM API are escape hatches for cases where the autoscaler isn't a good fit (e.g. you want a hard guarantee for a benchmark, or you're scripting your own logic).12345await sandbox.setAutoscale({ enabled: true, minMemoryMB: 1024, maxMemoryMB: 16384, });
minMemoryMB and maxMemoryMB must be values from the tier table above. The autoscaler keeps the sandbox between these bounds, in tier steps.scale call disables autoscale on that sandbox. Re-enable explicitly via setAutoscale({ enabled: true, ... }) (or the equivalent in any SDK) if you want it back.1await sandbox.setAutoscale({ enabled: false });
12const cfg = await sandbox.getAutoscale(); // { sandboxID: "sb-...", enabled: true, minMemoryMB: 1024, maxMemoryMB: 16384 }
scale from your application or operator tooling:1await sandbox.scale({ memoryMB: 4096 });
scaling_locked — the sandbox is locked. See Locking Resources.oom_floor — the requested size would force a guest OOM-kill because the current working set exceeds it. Free memory inside the guest, then retry.http://169.254.169.254 that lets code inside the VM scale itself. Useful for workload-aware scripts where the workload knows its own demand better than the platform autoscaler can infer (e.g. "scale up before this build, back down after").POST to /v1/scale with the desired memory in MB. CPU is adjusted proportionally.123curl -s -X POST http://169.254.169.254/v1/scale \ -H "Content-Type: application/json" \ -d '{"memoryMB": 4096}'
1curl -s http://169.254.169.254/v1/limits
cargo to scale up before compilation and scale back down after:12345678910111213141516alias cargo='_cargo_scaled' _cargo_scaled() { # Scale up to 16GB / 4 vCPU before build curl -sf -X POST http://169.254.169.254/v1/scale \ -H "Content-Type: application/json" -d '{"memoryMB": 16384}' # Run the actual cargo command command cargo "$@" local exit_code=$? # Scale back down to 4GB / 1 vCPU curl -sf -X POST http://169.254.169.254/v1/scale \ -H "Content-Type: application/json" -d '{"memoryMB": 4096}' return $exit_code }
~/.bashrc or inject it via sandbox.exec.run so every cargo build, cargo test, etc. automatically gets the extra resources.1234567891011121314151617181920212223242526272829303132333435363738394041#!/bin/sh SCALE_API="http://169.254.169.254/v1/scale" MIN_MB=1024 MAX_MB=8192 SCALE_UP_THRESHOLD=80 SCALE_DOWN_THRESHOLD=30 COOLDOWN=30 last_scale=0 while true; do mem_total=$(awk '/MemTotal/{print $2}' /proc/meminfo) mem_avail=$(awk '/MemAvailable/{print $2}' /proc/meminfo) usage_pct=$(( (mem_total - mem_avail) * 100 / mem_total )) total_mb=$((mem_total / 1024)) now=$(date +%s) elapsed=$((now - last_scale)) if [ $usage_pct -gt $SCALE_UP_THRESHOLD ] && [ $elapsed -gt $COOLDOWN ]; then new_mb=$((total_mb * 2)) [ $new_mb -gt $MAX_MB ] && new_mb=$MAX_MB if [ $new_mb -gt $total_mb ]; then echo "usage=$usage_pct% -> scaling UP to ${new_mb}MB" curl -sf -X POST "$SCALE_API" \ -H "Content-Type: application/json" \ -d "{\"memoryMB\":$new_mb}" last_scale=$now fi elif [ $usage_pct -lt $SCALE_DOWN_THRESHOLD ] && [ $total_mb -gt $MIN_MB ] && [ $elapsed -gt $COOLDOWN ]; then new_mb=$((total_mb / 2)) [ $new_mb -lt $MIN_MB ] && new_mb=$MIN_MB if [ $new_mb -lt $total_mb ]; then echo "usage=$usage_pct% -> scaling DOWN to ${new_mb}MB" curl -sf -X POST "$SCALE_API" \ -H "Content-Type: application/json" \ -d "{\"memoryMB\":$new_mb}" last_scale=$now fi fi sleep 5 done
1await sandbox.setScalingLock(true);
scale returns 403 scaling_lockedsetAutoscale({ enabled: true }) returns 403 scaling_locked123456// Unlock await sandbox.setScalingLock(false); // Inspect const lock = await sandbox.getScalingLock(); // { sandboxID: "sb-...", locked: false }