Resource Configuration

One Machine class, two backends. ResourceSpec configures a machine’s CPU, memory, disk, network, and GPU on either backend of the smolmachines SDK (Node) / smol module (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

const machine = await Machine.create({
  name: 'high-performance',
  resources: {
    cpus: 4,
    memoryMb: 2048
  }
});
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 fieldPython fieldTypeDefaultDescription
cpuscpusnumberengine defaultNumber of vCPUs
memoryMbmemory_mbnumberengine defaultMemory in MB
networknetworkbooleanfalseEnable outbound network access (TSI; TCP/UDP only, not ICMP)
allowCidrsallow_cidrsstring[]noneScope egress to these CIDR ranges (enables networking). Cloud only
allowHostsallow_hostsstring[]noneScope egress to these hosts and subdomains (enables networking). Cloud only
storageGbstorage_gbnumber20Storage disk size in GB
overlayGboverlay_gbnumber10Overlay (writable layer) disk size in GB
gpugpubooleanfalseEnable GPU acceleration (details). Local only
gpuVramMibgpu_vram_mibnumberengine defaultGPU 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 GB
  • overlayGb: 10 GB
  • gpu: 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']);