Virtualization Fundamentals Series

📊 Understanding Hyper-V Virtual Machine Resource Design from a "Top 1%" Perspective — How Far Can You Overcommit CPU and Memory?

Introduction

This article is part of the Top 1% Series’ full article guide, and the second article in the Virtualization Fundamentals Series. See What Is Proxmox VE? Understanding KVM/QEMU Virtualization from the “Top 1%” Perspective for the basic mechanics of virtualization (explained using KVM/QEMU as an example).

Prerequisites

Getting the Big Picture

CPU and Memory Have Completely Different Tolerances for Overcommitting

When assigning CPU and memory to Hyper-V virtual machines, the starting point for resource design is understanding a key difference in nature between the two: “overcommitting CPU is common practice, but overcommitting memory requires much more careful design.”

graph TB
    subgraph Cpu["CPU (a resource shared by dividing time)"]
        CpuNote["Waiting just means processing gets slower"]
    end
    subgraph Memory["Memory (a resource shared by dividing space)"]
        MemoryNote["Running short immediately triggers swapping (evicting to disk),<br/>causing performance to degrade dramatically"]
    end

Fundamentals, Explained Thoroughly

CPU Overcommit: Tolerance Stemming From Time-Slicing

CPU is a resource shared by having multiple virtual machines’ virtual processors (vCPUs) take turns using a physical CPU core’s execution time, in extremely short time slices. On the premise that it’s rare in practice for every virtual machine to demand 100% CPU at the same time, CPU overcommit — assigning a total vCPU count exceeding the physical core count — is a widely practiced, common design technique.

The specific ratio (how many vCPUs to assign per physical core) varies significantly depending on the nature of the workload running on the virtual machine. A workload with low CPU utilization, with only intermittent bursts of processing (a typical business system, for example) can tolerate a relatively high overcommit ratio, but a workload with consistently high CPU utilization (a database server, for example) needs a low overcommit ratio, or a design avoiding overcommit entirely.

Memory Overcommit: Strictness Stemming From Space-Division

Memory, too, can technically be assigned to virtual machines in a total amount exceeding physical memory, using Hyper-V’s Dynamic Memory feature. But unlike CPU, memory triggers serious performance degradation the instant it runs short — a decisively different characteristic.

If CPU runs short, a virtual machine simply waits longer in queue (processing slows down) — that’s the extent of the impact. If memory runs short, on the other hand, the OS evicts infrequently used data to a page file on disk (swapping). Disk access is orders of magnitude slower than memory access, so once memory swapping occurs, the entire system’s responsiveness degrades dramatically. This asymmetry is why CPU overcommit is widely accepted, while memory overcommit demands far more careful design.

How Hyper-V’s Dynamic Memory Works

Hyper-V’s Dynamic Memory operates based on three values you set for a virtual machine:

SettingMeaning
Startup RAMThe initial amount of memory assigned when the virtual machine boots
Minimum RAMThe minimum amount of memory it can shrink to while running
Maximum RAMThe maximum amount of memory it can grow to while running

Dynamic Memory is a mechanism that continuously monitors how much memory is actually being used within a virtual machine, and dynamically increases or decreases its memory allocation as needed, within the range from Minimum RAM to Maximum RAM. This lets memory that’s actually sitting idle on one virtual machine get redirected to another virtual machine that needs it, improving the overall efficiency of physical memory usage.

graph LR
    subgraph VmA["VM A (currently using little memory)"]
        A["Shrinks its allocation toward Minimum"]
    end
    subgraph VmB["VM B (currently needing a lot of memory)"]
        B["Expands its allocation toward Maximum"]
    end
    Host["The host's physical memory (fixed total)"]
    Host --> VmA
    Host --> VmB

Setting Minimum RAM too low carries the risk that a virtual machine won’t be guaranteed the memory it genuinely needs, potentially triggering swapping. Even when using Dynamic Memory, it’s important to correctly estimate each virtual machine’s actual minimum memory requirement.

The View From the Top 1% Perspective

Designing With NUMA (Non-Uniform Memory Access) in Mind

Large physical servers use an architecture called NUMA (Non-Uniform Memory Access), where each CPU socket has a dedicated region of memory assigned to it. If the amount of vCPU and memory assigned to a virtual machine crosses the boundary of a single NUMA node (i.e., it needs to access memory belonging to a different CPU socket), extra access latency can occur, degrading performance. When designing a large virtual machine, a practical performance consideration is factoring in that host’s NUMA layout (physical core count and memory per CPU socket), and assigning resources within a single NUMA node’s range wherever possible.

The Importance of Ongoing Capacity Planning

CPU and memory overcommit ratios aren’t a one-time design decision — an operational cycle of continuously monitoring actual utilization with a performance monitor, and periodically reviewing any gap between what was assumed and what’s actually happening, is important. In practice, adding new virtual machines or a change in an existing workload’s characteristics frequently makes an initially designed ratio no longer appropriate.

Common Misconceptions and Pitfalls

The Troubleshooting Perspective

For virtual machine performance issues, the basic approach is to isolate whether the problem is CPU contention, or memory swapping.

  1. A specific virtual machine feels sluggish overall: Check that host’s CPU utilization and vCPU wait time (CPU wait), and check whether CPU overcommit has become excessive.
  2. A specific virtual machine is extremely slow, particularly for operations involving disk I/O: Check whether memory swapping is occurring. If using Dynamic Memory, check whether the Minimum RAM setting is too low relative to what’s actually needed.
  3. Only a large virtual machine underperforms expectations: Check that host’s NUMA layout, and whether the assigned vCPU/memory crosses the boundary of a single NUMA node.

Preventive Measures and Permanent Fixes

Summary

What to Keep in Mind From Today

  1. When considering CPU and memory overcommit ratios, keep in mind their tolerances are completely different, and don’t decide both using a single criterion.
  2. When using Dynamic Memory, always confirm the Minimum RAM setting reflects each virtual machine’s actual requirement.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).