On a dual-socket dedicated server, memory is physically partitioned into NUMA nodes: each CPU owns a slice of RAM and pays a lower latency to reach its own slice than the other socket’s. Linux, left to its own devices, is a reasonable scheduler but not a perfect one, and it will happily migrate a database thread across sockets mid-query. Each migration turns a ~80 ns local memory access into a ~140–170 ns remote access across the inter-socket link, and at tens of thousands of accesses per millisecond that compounds into visible tail latency.
NUMA pinning is the practice of binding processes and their memory allocations to a single node so those remote hops never happen. It is one of the few tuning levers on a rented dedicated server that costs nothing and routinely buys 10–30% on p99 latency for databases and game server tick loops.
How NUMA Topology Looks on a Rented Host
On a dual-socket EPYC or Xeon box, lscpu will show two NUMA nodes and a cross-node distance matrix, usually 10 for local and 21 or 32 for remote. Dual-socket EPYC with a single memory controller per socket presents two nodes; some Xeon configurations expose four or even eight by splitting each socket’s memory channels.
Confirm the topology before writing any tuning rules, because the correct pinning differs for two nodes versus four. Run lscpu | grep NUMA and numactl --hardware together. If the host is a single-socket dedicated machine, NUMA tuning is mostly a no-op and your latency effort is better spent on choosing hardware with higher single-core clock.
The Cost of a Remote Memory Access
Local DRAM access on current server silicon runs 70–90 ns. Remote access over AMD Infinity Fabric or Intel UPI runs 130–180 ns depending on generation. That is a 2x penalty on every cache miss that crosses sockets, and databases miss cache constantly when scanning index pages larger than L3.
The penalty is not uniform. Bandwidth falls too: cross-socket traffic is limited by the interconnect width, not the memory bus. A workload that saturates memory bandwidth on one socket will queue behind the link when it spills across. This is why NUMA effects show up as bandwidth stalls in some workloads and as pure latency in others.
Detecting NUMA-Related Latency
The tell-tale signature is a bimodal latency distribution: most requests fast, a long tail at roughly 1.7x median. If your p50 is 0.8 ms and p99 is 4.2 ms on a query that should be uniform, NUMA migration is a prime suspect. Confirm with numastat -p <pid>, which reports how much memory each process pulled from remote nodes.
A non-zero numa_foreign value combined with a high numa_hit ratio across two nodes indicates the process is allocating on both sockets. For a game server tick loop, the more reliable signal is jitter in frame time that correlates with nothing in the game logic — that is scheduler migration, not simulation cost.
numactl Command Reference
| Command | Effect | Use when |
|---|---|---|
numactl --hardware | Show node topology and free memory per node | Always, first step |
numactl --show | Show current process policy | Verifying inherited defaults |
numactl --cpunodebind=0 --membind=0 CMD | Run on node 0 CPUs and allocate only on node 0 | Single-instance database |
numactl --interleave=all CMD | Round-robin allocations across all nodes | Large shared-cache workloads |
numactl --physcpubind=0-7 CMD | Pin to specific logical CPUs | Dedicated cores per service |
numactl --preferred=1 CMD | Prefer node 1 but allow overflow | Memory larger than one node |
numastat -p PID | Per-process node allocation report | Diagnosing remote allocations |
--membind is strict and will fail allocation rather than fall back, which is what you want for a database that must stay local. --preferred is the safer choice for anything whose working set might grow past one node — it degrades gracefully instead of OOMing.
Database Workloads: PostgreSQL and MySQL
PostgreSQL’s shared buffers behave badly under strict pinning when the buffer pool is larger than one node’s memory. The pragmatic pattern is to pin the backend processes to one node and interleave the shared buffer allocation. Set numactl --interleave=all at postmaster start, or tune huge_pages and let the pool span both sockets evenly.
MySQL and InnoDB prefer strict pinning because the buffer pool is allocated up front and does not resize. Pin mysqld to node 0 with --cpunodebind=0 --membind=0 and set innodb_buffer_pool_size to no more than 80% of node 0’s capacity. This keeps every page fault local and typically cuts p99 query latency by a quarter on a dual-socket box.
Game Servers and Latency-Sensitive Daemons
A game server tick loop wants one core, isolated, on the same node as its entity data. Use --physcpubind to pin the process to a dedicated core and --membind to keep its heap local, then set the kernel’s isolcpus parameter to remove that core from the general scheduler. Combine this with irqbalance exclusion so network interrupts do not steal the core.
For multi-instance game hosting, run each instance pinned to its own core-and-node pair rather than letting the scheduler pack them. Two instances on eight cores across two nodes should be pinned four-and-four, not allowed to float. This is the same discipline as CPU pinning for realtime audio, and it is documented alongside other hardware tuning practices for dedicated hosts.
Pitfalls: Over-Pinning and Cgroup Conflicts
The most common mistake is pinning everything strictly and then wondering why a memory-hungry service OOMs. Strict --membind on a process that grows past one node fails allocations rather than spilling. Reserve strict binding for processes with bounded, known working sets.
The second mistake is stacking NUMA policy under a container runtime or systemd unit that already sets AllowedCPUs. The narrower constraint wins silently, and you end up debugging latency that is actually a three-core cpuset. Check taskset -cp <pid> after starting any service to confirm the effective mask matches your intent.

Leave a Reply
You must be logged in to post a comment.