Skip to content

Resource Configuration โ€‹

Configure CPU and memory limits for machinees.

Basic Configuration โ€‹

typescript
const machine = await Machine.create({
  name: 'high-performance',
  resources: {
    cpus: 4,
    memoryMb: 2048
  }
});
python
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)

Default Resources โ€‹

If not specified, machinees use:

  • 1 vCPU
  • 512 MB memory

Resource Examples โ€‹

Minimal (CI tasks) โ€‹

typescript
resources: {
  cpus: 1,
  memoryMb: 256
}

Standard (most workloads) โ€‹

typescript
resources: {
  cpus: 2,
  memoryMb: 1024
}

High Performance (ML, compilation) โ€‹

typescript
resources: {
  cpus: 4,
  memoryMb: 4096
}

Best Practices โ€‹

Match Workload Needs โ€‹

Don't over-allocate resources. More vCPUs doesn't always mean faster:

typescript
// 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:

python
# 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:

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