Skip to content

NUMA Explained: Why Memory Distance Still Matters Inside Modern Servers

A 64-core, 512 GB server looked healthy on paper, yet query latency was inconsistent. The root cause wasn’t PostgreSQL, storage, or the network. It was memory locality. Understanding NUMA changes how you think about databases, Kubernetes, and AI infrastructure.

Published
Reading time
5 min
Topics
infrastructure, database
Cover illustration for "NUMA Explained: Why Memory Distance Still Matters Inside Modern Servers"

Last year, I was helping investigate a performance issue on a large database server.

The machine looked impressive on paper:

  • 64 CPU cores
  • 512 GB RAM
  • NVMe storage
  • CPU utilization below 50%

Yet query latency was inconsistent. Some requests completed in milliseconds while others took significantly longer. Disk I/O looked healthy. Network metrics were clean. Nothing obvious appeared wrong.

The root cause wasn’t PostgreSQL.

It wasn’t storage.

It wasn’t the network.

It was memory locality.

Specifically, NUMA.

Many engineers assume that a server’s memory behaves like a single, equally accessible pool. That assumption stops being true once you move beyond a single CPU socket.

Understanding NUMA is one of those rare topics that permanently changes how you think about databases, distributed systems, Kubernetes, AI infrastructure, and high-performance applications.

The Scaling Problem That Created NUMA

In early multiprocessor systems, CPUs shared access to a common memory subsystem.

Conceptually it looked like this:

CPU1 --> RAM
CPU2 --> RAM
CPU3 --> RAM
CPU4 --> RAM

This worked well until CPU counts started increasing.

As more processors competed for the same memory bus, memory access became the bottleneck. CPUs spent more time waiting than computing.

The industry needed a way to scale CPU count and memory capacity without creating a massive contention point.

The solution was NUMA.

NUMA stands for Non-Uniform Memory Access.

The keyword is “non-uniform.”

Not all memory accesses cost the same anymore.

A Better Mental Model

Imagine a company with two office buildings.

Each building contains:

  • Employees
  • File cabinets
  • Printers

Accessing resources inside your own building is fast.

Accessing resources in the other building requires crossing the street, coordinating with another office, and waiting for a response.

The resources are available.

They’re just farther away.

Modern multi-socket servers behave similarly.

A dual-socket server may appear as:

  • 64 cores
  • 512 GB RAM

But internally it is often closer to:

NUMA Node 0
  - 32 cores
  - 256 GB RAM
NUMA Node 1
  - 32 cores
  - 256 GB RAM

Each CPU socket has memory physically attached to it.

Accessing local memory is fast.

Accessing memory attached to another socket is slower.

The memory exists in one operating system view, but the physical reality underneath matters.

What Actually Happens Inside the Server

A simplified topology might look like this:

CPU0 --> RAM0
CPU1 --> RAM1
CPU0 <-->|Interconnect| CPU1

When a thread running on CPU0 accesses RAM0:

CPU0 → RAM0

The access remains local.

When that same thread accesses RAM1:

CPU0 → CPU1 → RAM1

The request must cross the socket interconnect before reaching memory.

That additional hop increases latency.

Individually, the difference may seem small.

At scale, it becomes significant.

Databases, search engines, JVM applications, and AI inference systems perform millions of memory operations every second. Small latency penalties accumulate into measurable throughput losses.

Why Databases Feel NUMA Pain First

Databases are particularly sensitive because their performance is often memory-bound rather than CPU-bound.

Consider a PostgreSQL instance with:

  • 128 GB shared buffers
  • Dozens of worker processes
  • Large active datasets

If most of the buffer pool ends up allocated on one NUMA node while workers execute across multiple nodes, many memory accesses become remote.

The symptoms often look misleading:

  • Increased query latency
  • Lower throughput
  • Higher CPU wait times
  • Unstable benchmark results

Engineers frequently start tuning PostgreSQL parameters, adding caches, or upgrading hardware.

Meanwhile, the real problem is memory placement.

This is one reason performance tuning on large database servers becomes increasingly hardware-aware.

Why AI Infrastructure Engineers Obsess Over NUMA

NUMA becomes even more important in modern AI systems.

A typical inference server may contain:

  • Two CPU sockets
  • Multiple GPUs
  • Hundreds of gigabytes of memory

The challenge is no longer just loading a model.

The challenge is loading it in the right place.

Imagine a GPU connected physically closer to CPU Socket 1 while model data resides primarily in memory attached to Socket 0.

Every transfer now crosses NUMA boundaries before reaching the GPU.

The result:

  • Lower throughput
  • Reduced bandwidth
  • Higher inference latency

This is why serious AI serving platforms pay attention to:

  • CPU affinity
  • Memory affinity
  • PCIe topology
  • NUMA topology
  • GPU placement

At scale, hardware locality directly impacts cost per token.

NUMA and Kubernetes

Many engineers think of scheduling like this:

Pod → Node

Modern servers are more complicated.

A large Kubernetes node may contain multiple NUMA domains.

A pod might receive:

  • CPU resources from NUMA Node 0
  • Memory from NUMA Node 2

The application works.

Performance suffers.

This becomes increasingly important for:

  • Databases
  • Machine learning workloads
  • Low-latency services
  • High-throughput caches

Features such as Kubernetes Topology Manager exist largely because locality matters.

The operating system can hide hardware complexity.

It cannot eliminate the physics underneath.

Production Lessons Engineers Learn the Hard Way

After enough performance investigations, several patterns appear repeatedly.

Low CPU Utilization Does Not Mean Resources Are Available

A server can show modest CPU usage while spending large amounts of time waiting on memory.

Many “CPU bottlenecks” are actually memory locality bottlenecks.

Bigger Servers Are Not Always Faster

Moving from:

32 cores

to:

128 cores

does not automatically produce a 4x improvement.

As socket counts increase, NUMA effects become more visible.

Scaling becomes constrained by:

  • Memory latency
  • Memory bandwidth
  • Cache coherency traffic
  • Cross-socket communication

Benchmark Results Can Lie

Engineers are often surprised when identical benchmark runs produce different results.

Sometimes nothing changed in the application.

The scheduler simply placed threads and memory differently.

NUMA placement alone can create surprisingly large performance variation.

How to Investigate NUMA Issues

Several Linux tools are worth knowing:

numactl --hardware

Shows NUMA topology.

numastat

Shows local and remote memory allocations.

lscpu

Provides CPU and NUMA node information.

perf stat

Helps identify memory stalls and cache-related bottlenecks.

For complex systems involving GPUs, storage devices, and accelerators, tools such as hwloc become extremely valuable for visualizing topology.

Final Thoughts

NUMA exists because the industry ran into the physical limits of shared-memory scaling.

The operating system presents a convenient abstraction: one machine, one memory space.

The hardware tells a different story.

Inside modern servers, distance still exists.

Some memory is closer.

Some memory is farther away.

Most applications can ignore this reality.

High-performance systems cannot.

If you’re working with large databases, AI inference servers, JVM applications, Kubernetes clusters, or high-throughput infrastructure, understanding NUMA is no longer an optimization topic.

It’s part of understanding how the machine actually works.

And once you start looking for NUMA effects, you’ll be surprised how many “software problems” turn out to be hardware locality problems.

Reactions

Comments

Leave a comment