Resource Configuration

Configure CPU and memory limits for machines.

TIP

There's no limit on how many machines you can create — machine count is never capped. Usage is measured by total vCPU and memory, not the number of machines.

Basic Configuration

const machine = await Machine.create({
  name: 'high-performance',
  resources: {
    cpus: 4,
    memoryMb: 2048
  }
});
from smolvm import MachineConfig, ResourceSpec

config = MachineConfig(
    name="high-performance",
    resources=ResourceSpec(
        cpus=4,
        memory_mb=2048
    )
)

Resource Options

OptionTypeDefaultDescription
cpusnumber4Number of vCPUs
memoryMb / memory_mbnumber8192Memory in megabytes (elastic via virtio balloon)
gpubooleanfalseEnable GPU acceleration (details)
networkbooleandefault applied by the server if omittedEnable networking
overlayGbnumberdefault applied by the server if omittedOverlay (writable layer) size in gigabytes
storageGbnumberdefault applied by the server if omittedPersistent storage size in gigabytes

Default Resources

If not specified, machines use:

  • 1 vCPU
  • 512 MB memory

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']);