Resource Configuration
One
Machineclass, two backends.ResourceSpecconfigures a machine’s CPU, memory, disk, network, and GPU on either backend of thesmolmachinesSDK (Node) /smolmodule (Python) — the embedded local engine (default) or the smolfleet cloud (ConnectOptions). Some fields apply to only one target (noted below). The standalone hosted REST API uses a different resource shape — see the Cloud API reference.
Configure CPU, memory, disk, and networking for machines via ResourceSpec.
Basic Configuration
TypeScriptconst machine = await Machine.create({
name: 'high-performance',
resources: {
cpus: 4,
memoryMb: 2048
}
}); Python from smol import Machine, MachineConfig, ResourceSpec
config = MachineConfig(
name="high-performance",
resources=ResourceSpec(
cpus=4,
memory_mb=2048
)
)
machine = Machine.create(config) Resource Options
ResourceSpec exposes the same fields in Node and Python (Node uses camelCase, Python uses snake_case):
| Node field | Python field | Type | Default | Description |
|---|---|---|---|---|
cpus | cpus | number | engine default | Number of vCPUs |
memoryMb | memory_mb | number | engine default | Memory in MB |
network | network | boolean | false | Enable outbound network access (TSI; TCP/UDP only, not ICMP) |
allowCidrs | allow_cidrs | string[] | none | Scope egress to these CIDR ranges (enables networking). Cloud only |
allowHosts | allow_hosts | string[] | none | Scope egress to these hosts and subdomains (enables networking). Cloud only |
storageGb | storage_gb | number | 20 | Storage disk size in GB |
overlayGb | overlay_gb | number | 10 | Overlay (writable layer) disk size in GB |
gpu | gpu | boolean | false | Enable GPU acceleration (details). Local only |
gpuVramMib | gpu_vram_mib | number | engine default | GPU VRAM in MiB when GPU is enabled. Local only |
Any field left unset is filled in by the engine. The SDK only sends the values you provide, so cpus and memoryMb fall back to the engine’s own defaults rather than a fixed SDK constant.
Default Resources
If not specified, the SDK documents these defaults:
network: disabled (false)storageGb: 20 GBoverlayGb: 10 GBgpu: disabled (false)cpus/memoryMb: chosen by the engine when omitted
Resource Examples
Minimal (CI tasks)
resources: {
cpus: 1,
memoryMb: 256
} Standard (most workloads)
resources: {
cpus: 2,
memoryMb: 1024
} High Performance (ML, compilation)
resources: {
cpus: 4,
memoryMb: 4096
} Best Practices
Match Workload Needs
Don’t over-allocate resources. More vCPUs doesn’t always mean faster:
// For I/O bound tasks, 1-2 CPUs is usually sufficient
const ioMachine = await Machine.create({
name: 'io-task',
resources: { cpus: 1, memoryMb: 512 }
});
// For CPU-intensive tasks, allocate more
const cpuMachine = await Machine.create({
name: 'cpu-task',
resources: { cpus: 4, memoryMb: 2048 }
}); Memory for Large Data
Python data processing often needs more memory:
# Processing large datasets
config = MachineConfig(
name="data-processing",
resources=ResourceSpec(
cpus=2,
memory_mb=4096 # 4GB for pandas/numpy
)
) Compilation Tasks
Compilation benefits from multiple cores:
const machine = await Machine.create({
name: 'builder',
resources: {
cpus: 4, // Parallel compilation
memoryMb: 2048 // Linking needs memory
}
});
await machine.run('rust:alpine', ['cargo', 'build', '--release', '-j4']);