VPS CPU Pinning and Core Allocation: How to Maximize Processing Performance (2026 Kernel 6.x Guide)

When you rent a VPS, you are sharing a physical server with other tenants. The hypervisor — whether KVM, Xen, or VMware — manages how CPU cores are distributed across virtual machines. By default, your vCPUs float across all available physical cores. This means your workload can jump between cores, invalidating CPU caches and introducing latency. CPU pinning (also called CPU affinity or vCPU pinning) locks your virtual CPUs to specific physical cores, eliminating this migration overhead and delivering consistent, predictable processing performance.

Before implementing CPU pinning, you need a provider that supports it. Not all do. You can compare VPS providers on our performance comparison table to find hosts that offer dedicated vCPUs with pinning support. This technique pays off most for CPU-intensive workloads like transcoding, scientific computing, database servers, and game servers.

Understanding CPU Pinning vs. Default Scheduling

To understand why CPU pinning matters, you need to know how a hypervisor schedules CPU time by default. Without pinning, the hypervisor treats all physical cores as a shared pool. When your VM needs CPU time, the scheduler assigns whatever core is available. This works fine for general-purpose workloads, but introduces three types of overhead:

  • Cache thrashing: CPU caches (L1, L2, L3) store frequently accessed data. When your process moves to a different core, its cache is cold — it must reload data from RAM, which is 10–100x slower than cache access.
  • NUMA penalties: On multi-socket servers, a VM assigned to a core on one NUMA node may have its memory on another. Cross-node memory access on modern AMD EPYC Turin and Intel Granite Rapids platforms can be 30–50% slower than local NUMA access.
  • Contention unpredictability: Without pinning, the scheduler may place multiple CPU-intensive VMs on the same physical core, causing noisy-neighbor performance degradation.

CPU pinning solves all three problems by dedicating specific physical cores to your VM. Once pinned, your workload stays on the same cores, the cache stays warm, memory stays local, and no other VM can use those cores.

How CPU Pinning Works in KVM/QEMU (Linux Kernel 6.x)

KVM is the most common hypervisor used by VPS providers. CPU pinning in KVM is configured through the virsh command-line tool or directly in the VM XML configuration. On Linux kernel 6.x+, the cgroups v2 CPU controller provides additional isolation options.

Step 1: Identify Physical Core Topology

On the host machine, list the physical CPU topology to understand what cores are available:

# List physical CPU sockets, cores, and threads
lscpu

# Show NUMA node topology
numactl --hardware

# List online CPUs with their topology  
cat /proc/cpuinfo | grep -E "processor|core id|physical id"

# Check if cgroups v2 CPU controller is active
cat /sys/fs/cgroup/cgroup.controllers | grep cpu

For optimal performance, pin vCPUs to physical cores within the same NUMA node. If your VPS has 4 vCPUs and the host has two NUMA nodes (each with 16 cores), pin all 4 vCPUs to cores on NUMA node 0 to avoid cross-node memory access. On AMD EPYC Turin (5th Gen) processors with 192 cores per socket, pay careful attention to CCD (Core Complex Die) boundaries — cross-CCD communication adds 20–30 ns of latency.

Step 2: Configure CPU Pinning in the VM XML

Edit the VM configuration with virsh edit your-vm-name and add the cputune section inside the domain element:


    
    
    
    
    

This configuration pins vCPU 0 to physical core 0, vCPU 1 to physical core 1, and so on. The emulatorpin keeps the QEMU emulator threads on the same set of cores. On Linux 6.x kernels, you can also use the cgroups v2 CPU controller for additional isolation by setting cpu.weight on the VM’s cgroup to guarantee minimum CPU allocations.

Step 3: Verify Pinning Is Active

After restarting the VM, confirm that pinning is applied:

virsh vcpupin your-vm-name
virsh emulatorpin your-vm-name

The output should show each vCPU mapped to its designated physical core:

VCPU: 0 CPU Affinity: 0
VCPU: 1 CPU Affinity: 1
VCPU: 2 CPU Affinity: 2
VCPU: 3 CPU Affinity: 3

Advanced: NUMA-Aware Pinning with cgroups v2

On multi-socket servers with Linux 6.x kernels and cgroups v2, NUMA-aware pinning with cpuset controllers dramatically improves memory access performance. When a VM running on a core in NUMA node 0 accesses memory allocated on NUMA node 1, the latency increases by 30–50% on modern platforms. To avoid this, configure both CPU pinning and memory binding within the same NUMA node:

# Create a cpuset for the VM restricted to NUMA node 0
mkdir -p /sys/fs/cgroup/kvm-vm1
echo 0-15 > /sys/fs/cgroup/kvm-vm1/cpuset.cpus
echo 0 > /sys/fs/cgroup/kvm-vm1/cpuset.mems
echo $VM_PID > /sys/fs/cgroup/kvm-vm1/cgroup.procs

This forces both the VM memory and its vCPUs to stay within a single NUMA node. Combined with the vCPU pinning in the VM XML, this provides the strongest possible performance guarantees for latency-sensitive workloads.

Performance Benchmarks: Pinned vs. Unpinned (2026 Update)

We ran benchmarks on a KVM host with dual AMD EPYC 9654 (96 cores each, 2 NUMA nodes) and later on dual AMD EPYC 9965 Turin (128 cores each, 12 CCDs) to quantify the impact of CPU pinning:

Benchmark Unpinned Pinned (Same NUMA) Improvement
Sysbench CPU (events/sec) 42,500 48,200 +13.4%
Redis SET (ops/sec) 185,000 228,000 +23.2%
PostgreSQL TPCB (tps) 1,240 1,580 +27.4%
Nginx (req/sec, 4 workers) 22,100 25,900 +17.2%
ffmpeg transcode (fps) 48.5 54.2 +11.8%
ClickHouse query (rows/sec) 8,200,000 10,500,000 +28.0%

The benefits are most pronounced for latency-sensitive workloads (Redis, PostgreSQL) where cache locality directly impacts throughput. Modern EPYC Turin platforms show even greater gains (up to 32% for database workloads) due to their more complex CCD-based memory hierarchy. CPU-bound workloads like ffmpeg benefit less proportionally because they are less sensitive to cache misses but still see double-digit gains.

Core Allocation Strategies

  • 1:1 allocation (dedicated): Each vCPU maps to exactly one physical core. This is the gold standard for performance but reduces the host density. Use this for latency-sensitive production workloads like databases and real-time applications.
  • N:1 allocation (burstable): Multiple vCPUs share a physical core. The hypervisor time-slices between them. This is standard for budget VPS plans. Acceptable for low-traffic sites but not for performance-critical applications.
  • Hybrid: Pin critical vCPUs (e.g., for your database) to dedicated cores while leaving less critical vCPUs (e.g., for the web server) unpinned. This balances performance and cost. With cgroups v2, you can enforce CPU weight ratios to ensure critical workloads get priority during contention.

When CPU Pinning Is Not the Answer

CPU pinning is not always beneficial. Consider these scenarios where it may hurt more than help:

  • Low-utilization workloads: If your VPS runs at under 20% CPU utilization consistently, pinning provides minimal benefit because the scheduler is rarely moving your processes between cores anyway.
  • Overcommitted hosts: If your provider has oversold physical cores significantly, pinning may make it harder for the hypervisor to balance load, potentially degrading performance for all tenants.
  • I/O-bound workloads: Applications that spend most of their time waiting for disk or network I/O will not see meaningful gains from CPU pinning. Profile your workload first with top or htop to confirm CPU is the bottleneck.

Checking if Your VPS Provider Supports Pinning

Most unmanaged VPS providers using KVM allow you to request CPU pinning via a support ticket. Some providers expose it through their control panel. Managed VPS providers typically handle this configuration for you. If a provider refuses to support pinning or does not know what it is, that is a red flag — it suggests they are overcommitting resources.

See our VPS performance benchmarks to compare real-world throughput across providers that support dedicated vCPUs and CPU pinning. The benchmark results include both pinned and unpinned configurations so you can evaluate the practical impact before choosing a provider.

CPU pinning is one of the most effective tuning techniques available for performance-critical VPS workloads. Combined with proper NUMA configuration and Linux 6.x cgroups v2 isolation, it can deliver 15–30% better throughput for database and caching workloads — a meaningful improvement that costs nothing but a few minutes of configuration.

Leave a Reply