Use this when deciding which VMs win CPU under contention.
CPU Shares
CPU shares set a VM's relative priority only when the host is contended: a VM with twice the shares gets about twice the CPU. Shares have no effect on an idle host and are inherited relative to resource pools.
1. Shares set relative priority only under contention.
2. No effect when the host is idle.
3. Higher shares for important VMs.
4. Shares are relative to siblings.
5. Prefer shares over limits.
contention → shares ratio → CPU time
Context & applicabilityCommon mistakes · platform/version boundaries
- Setting all VMs to High (no effect relative to each other).
- Ignoring shares on resource pools when VMs inside get less than expected.
- Expecting shares to help without contention.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Shares are relative weights, not guaranteed amounts.
- They only matter while the host is contended.
- VMs in a pool share the pool's allocation.
qm set <vmid> --cpuunits 2048— weight (Proxmox; default 100 cgroup v2)Set-VMProcessor <vm> -RelativeWeight 200— Hyper-V weightvirsh schedinfo <vm> --set cpu_shares=2048— libvirt
ReferenceWhy it matters1 section · depth on demand
Values
| Level (vSphere) | Shares per vCPU |
|---|---|
| Low | 500 |
| Normal | 1000 |
| High | 2000 |
Shares are relative and only apply under contention. In resource pools the pool's shares are split among its VMs, so a pool with 50 VMs at High can give each VM less than a lone VM at Normal in another pool. KVM equivalent: cpu.weight (cgroup) / cpuunits in Proxmox.
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
Shares are weights, only under contention
CPU shares decide how host CPU time is divided when VMs compete; an idle host lets any VM use what it needs. The libvirt domain format documents <cputune><shares> as a relative weight whose range depends on cgroups v1 or v2.
| Platform | Setting | Default |
|---|---|---|
| Proxmox VE | --cpuunits | 100 with cgroup v2 (1024 on old cgroup v1 hosts) |
| libvirt | <cputune><shares>N</shares></cputune> | Derived from vCPU count on older libvirt; 100 under cgroup v2 |
| vSphere | Shares Low/Normal/High (500/1000/2000 per vCPU) | Normal |
Worked example under contention
Host with 8 cores fully busy, three VMs each wanting all of it:
| VM | cpuunits | Share of CPU time |
|---|---|---|
| db01 | 400 | 400 / 600 = 67 % |
| app01 | 100 | 17 % |
| batch01 | 100 | 17 % |
Shares vs. limits vs. pinning
| Tool | Proxmox / libvirt | Effect |
|---|---|---|
| Shares | cpuunits / <shares> | Relative priority only when busy |
| Limit | cpulimit 2 / <period>+<quota> | Hard cap (2 = two cores' worth) even when the host is idle |
| Pinning | affinity 0-3 / <vcpupin> | Restrict to specific host CPUs |
Limits cause latency at quota boundaries (throttling); prefer shares for prioritisation and limits only for noisy or untrusted workloads.
Verify on the host (cgroup v2)
cat /sys/fs/cgroup/qemu.slice/101.scope/cpu.weight
cat /sys/fs/cgroup/qemu.slice/101.scope/cpu.stat | grep throttled
Rising nr_throttled means a limit is actively slowing the VM — a frequent hidden cause of "the VM is slow but the host is idle".
Equivalents on other platforms
| Platform | Setting | Default |
|---|---|---|
| Hyper-V | Processor Relative weight (Set-VMProcessor -RelativeWeight) | 100 (range 1–10,000) |
| Proxmox | cpuunits (qm set 101 --cpuunits 200) | 100 on cgroup v2 |
| libvirt | <cputune><shares> | Depends on cgroup version |
As on vSphere, these weights only matter when the host CPU is contended.
Worked example
CPU shares (weights) only matter when CPUs are contended: each VM gets CPU proportional to its shares among competing VMs.
| Platform | Setting | Default |
|---|---|---|
| VMware | Low/Normal/High = 500/1000/2000 per vCPU | Normal |
| Hyper-V | Relative weight 0–10000 | 100 |
| Proxmox | cpuunits (cgroup v2 weight 1–10000) | 100 |
Worked example: two VMs compete for one core, VM A has 2000 shares and VM B 1000 → A gets about two thirds of the time, B one third. When B is idle, A can use the full core.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Resource Management → CPU Shares. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/html/libvirt-libvirt-domain.html · confidence 94%