Proxmox · Resources

Proxmox Resource Limits: CPU/Memory Overcommit and Ballooning Explained

Resource overcommit allows you to extract maximum density from your homelab hypervisor — dynamically balancing CPU scheduling, VirtIO memory ballooning, and ZFS ARC limits without triggering the Linux OOM killer.

Quick idea: Squeezing twenty virtual machines onto a single 64 GB host isn’t black magic; it’s statistical multiplexing. Because idle homelab workloads rarely spike simultaneously, CPU weights (cpuunits) and VirtIO memory ballooning let KVM dynamically shift spare RAM and processor cycles to whichever guest is actively doing work.
CPU Multiplexing

Assigning more vCPUs than physical cores relies on the Linux Completely Fair Scheduler; cpuunits priorities keep your firewall responsive when builds spin up.

VirtIO Ballooning

An in-guest driver inflates to reclaim unused guest RAM for the host, deflating on demand when the virtual machine actually needs memory.

KSM Deduplication

Kernel Samepage Merging scans physical RAM in the background to merge duplicate memory pages across identical Linux and Windows guests.

What Is Resource Overcommit?

If you run a homelab, you quickly hit the harsh economic reality of server hardware: RAM is expensive, high-core processors consume electricity, and running three power-hungry rack servers in the living room ruins the household noise floor. To keep your power bill sensible and maintain a healthy household approval factor, the name of the game is packing as many workloads as possible onto compact, power-efficient nodes like mini PCs or single-socket workstations.

That is where resource overcommit enters the picture. Resource overcommit simply means allocating more virtual compute (vCPUs) or virtual memory (vRAM) across all your virtual machines than the physical server actually possesses in hardware.

Think of resource overcommit like a busy coffee shop with ten tables. If the owner insisted that every person who might drop by today must have a dedicated, reserved table sitting empty for eight hours just in case they show up, the café would go bankrupt by lunchtime. Instead, customers arrive, drink an espresso, read for twenty minutes, and leave. As long as twenty customers do not try to sit down at the exact same second, ten tables easily service fifty people a day.

Virtual machines behave identically. Your domain controller, DNS resolver, reverse proxy, monitoring stack, and developer test machines spend 95% of their lives sitting at 1% CPU utilisation, waiting for an incoming packet or a cron job. If you rigidly dedicate 8 GB of physical RAM and 4 physical cores to each VM, a 64 GB host caps out at six or seven machines. With intelligent overcommit, that exact same physical box comfortably runs twenty or thirty.

Key distinction: CPU overcommit and memory overcommit operate on fundamentally different physics. CPUs are scheduled in time (if two VMs want a core, the scheduler time-slices between them, causing minor latency). Memory is allocated in space (if two VMs demand physical RAM bytes that do not exist, something must be paged to disk or killed). Time can be shared; space cannot.

Why Ballooning Instead of Fixed Allocations?

When you create a standard KVM virtual machine in Proxmox with fixed memory (say, 8192 MB), QEMU requests an 8 GB virtual address space allocation from the Linux host kernel right at boot. While Linux utilizes lazy page allocation (only allocating physical 4 KB pages as the guest touches them), modern operating systems immediately wipe and initialise memory during startup. Furthermore, Linux guests use spare RAM for file page caches, and Windows aggressively pre-fetches libraries.

Within an hour of booting, a VM assigned 8 GB will cause the host to commit almost all 8 GB of physical RAM, even if the application inside is only using 800 MB!

Enter VirtIO Memory Ballooning.

Instead of a rigid boundary, ballooning installs a cooperative driver (virtio_balloon) inside the guest operating system. When the Proxmox host experiences memory pressure, it communicates with the guest driver through the hypervisor bus and orders the balloon to inflate.

When the balloon inflates, the in-guest driver allocates memory from the guest OS kernel just like any regular greedy application. The guest operating system flushes clean file caches, discards unneeded buffers, and hands those pages to the balloon driver. The balloon driver then notifies the Proxmox host: “I am holding these physical pages; you can take them back.” The host hypervisor unmaps those physical pages, immediately freeing up RAM for other virtual machines.

Conversely, when the guest application suddenly needs to perform a heavy compile or process a large database query, the guest OS requests memory. The balloon driver deflates, shrinking its allocation and returning the physical RAM to the guest.

Homelab tip: Always install and enable the QEMU Guest Agent (qemu-guest-agent) inside every VM. Without the guest agent, Proxmox reads memory usage solely from the host’s perspective, which includes guest page caches, displaying a terrifying 95% RAM utilisation on completely idle machines. The guest agent reports actual in-guest usage back to the web GUI.

How KVM and Proxmox Manage Host Memory

Under the hood of Proxmox VE, memory management is a coordinated dance between the Linux kernel, the QEMU process monitor, and guest drivers. Understanding this memory pipeline is what prevents unexpected host lockups:

┌────────────────────────────────────────────────────────────────────────┐
│                        Proxmox Physical RAM (Host)                    │
│   ┌───────────────────┬────────────────────┬───────────────────────┐   │
│   │   Proxmox OS &    │    ZFS ARC Cache   │   KVM Guest VM RAM    │   │
│   │   Core Daemons    │   (zfs_arc_max)    │      (QEMU Pool)      │   │
│   └───────────────────┴────────────────────┴───────────────────────┘   │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
                  ┌─────────────────┴─────────────────┐
                  ▼                                   ▼
┌───────────────────────────────────┐   ┌────────────────────────────────┐
│   Kernel Samepage Merging (KSM)   │   │     VirtIO Balloon Driver      │
│ Scans memory pages across VMs.    │   │ Inflates inside guest to force │
│ De-duplicates identical OS blocks │   │ cache reclamation back to host.│
└───────────────────────────────────┘   └────────────────────────────────┘
                  │                                   │
                  └─────────────────┬─────────────────┘
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                        Guest Operating System                          │
│   ┌────────────────────────────────────────┬───────────────────────┐   │
│   │   Active Applications (Database/Web)   │ In-Guest File Buffers │   │
│   └────────────────────────────────────────┴───────────────────────┘   │
└────────────────────────────────────────────────────────────────────────┘

Proxmox layers three distinct technologies to keep overcommitted memory stable:

1. Ballooning Thresholds: Proxmox runs an automatic ballooning daemon (pvestatd). By default, Proxmox aims to keep host memory consumption around 80%. If host memory exceeds that mark, it commands guest balloons to inflate until the host drops below target.

2. Kernel Samepage Merging (KSM): KSM is a Linux kernel feature that periodically scans physical memory looking for pages with identical content. If you run four Debian 12 VMs and three Windows Server 2025 VMs, large chunks of system binaries and shared libraries are byte-for-byte identical. KSM merges those into a single copy-on-write page, saving gigabytes of physical RAM.

3. The ZFS ARC Trap: If your Proxmox boot or VM storage pool runs on ZFS (which we covered in our ZFS on Proxmox guide), ZFS uses the Adaptive Replacement Cache (ARC) to cache hot reads in RAM. By default, ZFS will greedily consume up to 50% of your total host RAM.

While ARC is designed to shrink when applications demand memory, it does not always yield quickly enough when several KVM VMs experience simultaneous memory spikes. When memory runs dry before ARC can release its buffers, the Linux kernel invokes the dreaded Out of Memory (OOM) Killer, which calculates a badness score and brutally terminates the largest QEMU process it can find!

Essential rule: If you run ZFS alongside virtual machines on a homelab node, you must manually cap zfs_arc_max. Leaving it at default defaults your node to an eventual OOM crash during heavy backup or scrub operations.

Configuration: VM Config Files and QEMU Directives

In Proxmox VE, VM configurations live in plain text under /etc/pve/qemu-server/<vmid>.conf. While the web interface provides checkboxes, inspecting the raw configuration file reveals exactly how the hypervisor constrains compute and memory.

Here is a production-grade configuration for a lab service (VM 104) tuned for dynamic ballooning and prioritized CPU scheduling:

# /etc/pve/qemu-server/104.conf
boot: order=scsi0;ide2
cores: 4
sockets: 1
cpu: host
cpuunits: 2048
cpulimit: 2.5
memory: 8192
balloon: 2048
agent: 1
scsihw: virtio-scsi-single
scsi0: local-zfs:vm-104-disk-0,discard=on,size=40G
net0: virtio=BC:24:11:AA:BB:CC,bridge=vmbr0,firewall=1
ostype: l26
Directive Value Example Purpose & Scheduling Behaviour
memory 8192 The maximum memory ceiling (in MB) the guest is allowed to consume.
balloon 2048 The minimum memory floor (in MB) guaranteed to the guest; the balloon will never inflate past this line.
cores 4 Number of virtual CPU cores presented to the guest OS.
cpuunits 2048 Relative CPU shares (default is 1024). A value of 2048 gives this VM twice the CPU scheduling weight under contention.
cpulimit 2.5 Hard ceiling on host CPU usage, expressed in physical core equivalents. Prevents a runaway loop from pinning all 4 cores.
agent 1 Enables communication with the QEMU Guest Agent for accurate memory statistics and graceful ACPI shutdowns.

Management Commands: Proxmox CLI Reference

While clicking through the Proxmox web interface is pleasant, administering resource limits across twenty machines is infinitely faster from the shell. Below is your operational command reference for configuring, inspecting, and tuning overcommit parameters.

# 1. Memory and Ballooning Configuration
# Configure dynamic memory: 8 GB maximum with a 2 GB guaranteed floor
qm set 104 --memory 8192 --balloon 2048

# Disable ballooning completely (assigns rigid fixed RAM, useful for latency-sensitive databases)
qm set 104 --balloon 0

# Adjust the node-wide automatic ballooning target percentage (default is 80)
pvenode config set --ballooning-target 85

# 2. CPU Overcommit and Weighting Configuration
# Assign 4 cores, grant high CPU scheduling priority (weight 2048), and cap total usage at 2 physical cores
qm set 104 --cores 4 --cpuunits 2048 --cpulimit 2

# Lower CPU priority for background batch scrapers or lab build sandboxes (weight 512)
qm set 108 --cpuunits 512

# 3. Live Monitoring and Diagnostics
# Query current balloon status and memory breakdown directly from the QEMU monitor
qm monitor 104
# (At the monitor prompt, type 'info balloon' and then 'quit')

# Check host-level memory usage and swap activity
free -h

# Check Kernel Samepage Merging (KSM) deduplication efficiency
cat /sys/kernel/mm/ksm/pages_sharing
cat /sys/kernel/mm/ksm/pages_shared

# Inspect whether the KSM daemon is actively running
systemctl status ksmtuned

# 4. Taming the ZFS ARC Memory Footprint
# Create a modprobe configuration to limit ZFS ARC maximum memory to 8 GB (8589934592 bytes)
cat << 'EOF' > /etc/modprobe.d/zfs.conf
options zfs zfs_arc_max=8589934592
EOF

# Update the initramfs to ensure the ZFS ARC limit applies during early boot
update-initramfs -u -k all

# Verify live ZFS ARC memory consumption
arcstat 1 5

Proxmox Resource Allocation Cheat Sheet

Not all workloads should be overcommitted equally. Squeezing memory from an Active Directory Domain Controller or a Plex transcoding container is fine; doing it to an in-memory Redis cluster or an etcd database will destroy your weekend. Use this guideline when provisioning:

Workload Type vCPU to Core Ratio Ballooning Recommendation Recommended cpuunits
Edge Firewall / Router (pfSense/OPNsense) 1:1 (Dedicated) Disabled (balloon = 0) 8192 (Highest)
Domain Controllers / DNS (Samba / AD DS) 2:1 to 3:1 Enabled (Min: 1 GB, Max: 3 GB) 2048 (High)
Relational Databases (PostgreSQL / MySQL) 2:1 Disabled (balloon = 0) 2048 (High)
Application / Web Services (Nginx / Docker) 3:1 to 4:1 Enabled (Min: 2 GB, Max: 8 GB) 1024 (Standard)
Developer Sandboxes / CI Runners 4:1 to 6:1 Aggressive (Min: 1 GB, Max: 16 GB) 512 (Low)

Troubleshooting Cheat Sheet: OOM Killer and Memory Freezes

When overcommit parameters are tuned too aggressively, the hypervisor shows warning signs long before an outright crash. Here is how to diagnose and resolve memory contention issues in Proxmox VE.

Symptom Observed Likely Root Cause How to Confirm & Fix
Virtual machine abruptly powers off with no guest shutdown logs Host Linux Out of Memory (OOM) killer terminated the kvm process to protect host kernel stability. Inspect host dmesg using dmesg -T | grep -i oom, reduce VM memory ceilings, and configure zfs_arc_max in /etc/modprobe.d/zfs.conf.
Proxmox Web GUI shows 95%+ RAM usage on an idle VM Missing or unstarted QEMU Guest Agent causing the host to misinterpret guest disk caching as active allocated RAM. Install the guest agent in the VM (apt install qemu-guest-agent or Windows MSI), enable agent in VM options, and restart the guest.
Windows guest stutters or shows high CPU usage in System process VirtIO balloon driver (balloon.sys) thrashing memory pages as host repeatedly forces inflation under memory pressure. Increase the minimum balloon floor with qm set <vmid> --balloon <higher-mb> or install the latest stable Red Hat VirtIO driver ISO.
High CPU “steal time” reported inside virtual machine guests Excessive CPU overcommit causing the host kernel scheduler to delay servicing guest virtual CPU threads. Check host CPU load with top, reduce vCPU core count across non-essential VMs, and prioritize critical VMs using cpuunits: 2048.
Host begins heavy swap thrashing and web UI becomes unresponsive Host RAM completely exhausted; swappiness default (60) causing Linux to aggressively page VM memory to slow disk. Lower host swappiness by setting vm.swappiness=10 in /etc/sysctl.d/pve.conf and execute sysctl -p to apply immediately.

Final Thoughts

Running an efficient homelab is all about striking the right balance between hardware efficiency and workload stability. With VirtIO memory ballooning, Kernel Samepage Merging, and prioritized CPU scheduling, Proxmox VE turns modest hardware into a high-density virtualization platform capable of running enterprise-scale lab topologies.

The golden rule is simple: treat latency-sensitive and storage-heavy applications (like your firewall, databases, and ZFS ARC) with conservative, dedicated memory, while allowing your stateless services and dev testboxes to balloon dynamically. Keep an eye on your swap metrics, cap your ZFS cache, and you will enjoy maximum VM density without unexpected midnight reboots.

Key takeaway: Overcommit CPU freely with cpuunits prioritization, but treat memory with respect. Cap zfs_arc_max, install the QEMU Guest Agent on every machine, and never set your balloon floor lower than what the guest operating system needs to survive idle operation.
Next in this series

Next, we will tackle Proxmox PCI Passthrough: configuring IOMMU groups, blacklisting host GPU drivers, and passing graphics cards and NVMe controllers directly into virtual machines.


Discover more from Karanth.ovh

Subscribe to get the latest posts sent to your email.