100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is NUMA Architecture?

NUMA explained — local vs remote memory latency, first-touch allocation, and NUMA-aware scheduling — with an interview-ready breakdown.

hardQ202 of 224 in Operating Systems Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

NUMA (Non-Uniform Memory Access) is a multiprocessor memory architecture where each CPU (or group of cores) has its own local memory bank that it accesses quickly, while accessing another CPU’s local memory over an interconnect is slower, so memory access latency depends on which node the data physically lives on relative to the accessing core.

In a NUMA system, physical memory is partitioned into nodes, each attached to a specific processor socket; a core reading from its own node’s memory pays local latency, but reading from a remote node’s memory crosses an interconnect (like Intel QPI or AMD Infinity Fabric) and pays extra latency and reduced bandwidth. The OS scheduler and memory allocator must be NUMA-aware: they try to allocate a process’s memory on the same node as the core it runs on (first-touch allocation) and prefer scheduling a thread on cores close to the memory it already touched, to avoid remote-access penalties. Migrating a thread to a different NUMA node without also migrating its memory can silently tank performance, since every memory access becomes a remote access; tools like Linux’s numactl and automatic NUMA balancing exist specifically to manage this. NUMA exists because as core counts grow, a single shared memory bus becomes a bottleneck — giving each socket its own local memory bank scales bandwidth, at the cost of non-uniform latency that software must be aware of.

  • Explains why memory latency is not uniform on multi-socket servers
  • Motivates NUMA-aware scheduling and first-touch memory allocation
  • Clarifies why moving a thread across sockets can hurt performance without a matching memory migration
  • Directly relevant to database and high-performance-computing tuning questions

AI Mentor Explanation

NUMA is like a franchise with two training grounds in different cities, each with its own equipment store: a player training at their home ground can grab gear instantly from the local store, but requesting gear from the other city’s store takes noticeably longer to arrive. If a player is suddenly reassigned to train at the other city’s ground without their gear following them, every equipment request becomes a slow cross-city trip. Smart team management keeps a player and their gear at the same ground whenever possible, exactly like NUMA-aware scheduling keeping a thread and its memory on the same node.

Step-by-Step Explanation

  1. Step 1

    Memory partitioned into nodes

    Physical memory is split into banks, each attached to a specific CPU socket (NUMA node).

  2. Step 2

    Local vs remote access

    A core reading its own node’s memory pays local latency; reading another node’s memory crosses an interconnect and pays extra latency.

  3. Step 3

    First-touch allocation

    The OS memory allocator places a new page on the NUMA node of the core that first touches it, aiming for locality.

  4. Step 4

    NUMA-aware scheduling

    The scheduler prefers keeping a thread on the same node as its memory, or migrates the memory along with the thread when it must move.

What Interviewer Expects

  • A precise definition: non-uniform latency because memory is partitioned per socket/node
  • Understanding of local vs remote access cost via an interconnect
  • Awareness of first-touch allocation and NUMA-aware scheduling as the OS-level mitigation
  • Recognition of why database/HPC tuning cares about NUMA (numactl, pinning)

Common Mistakes

  • Confusing NUMA with simple cache hierarchies (L1/L2/L3)
  • Assuming all multi-core systems are NUMA (single-socket systems are typically UMA)
  • Not knowing that migrating a thread without its memory can hurt performance
  • Forgetting that first-touch allocation, not allocation time alone, determines the NUMA node

Best Answer (HR Friendly)

NUMA means that on a multi-socket server, each processor has its own chunk of memory that it can reach quickly, but reaching memory attached to a different processor takes longer. Because of this, a NUMA-aware operating system tries to keep a program’s data on the same processor that is actually running it, so it does not pay that extra cross-socket delay on every memory access.

Code Example

Querying and pinning memory to the local NUMA node (libnuma-style)
#include <numa.h>

void run_on_local_node(void) {
    if (numa_available() < 0) {
        return;   /* system is not NUMA, nothing to optimize */
    }

    int current_node = numa_node_of_cpu(sched_getcpu());

    /* Bind future memory allocations in this thread to the local node,
       avoiding costly remote-node accesses across the interconnect */
    numa_set_preferred(current_node);

    void *buf = numa_alloc_onnode(1024 * 1024, current_node);
    /* ... use buf on this same core to keep access local ... */
    numa_free(buf, 1024 * 1024);
}

Follow-up Questions

  • What is first-touch memory allocation and how does it relate to NUMA?
  • What happens to performance if a thread is migrated to a different NUMA node without its memory?
  • How does automatic NUMA balancing in Linux try to fix bad placement over time?
  • How does NUMA interact with load balancing across cores?

MCQ Practice

1. What does NUMA stand for and describe?

NUMA systems partition memory into per-socket nodes, so accessing local memory is faster than accessing a remote node over the interconnect.

2. What is “first-touch” allocation in a NUMA-aware OS?

First-touch allocation places a page on the NUMA node of whichever core first accesses it, aiming for locality between the thread and its memory.

3. What risk arises from migrating a thread to a different NUMA node without migrating its memory?

If the thread’s memory stays on the original node, every access after migration crosses the interconnect, silently hurting performance.

Flash Cards

What is NUMA?Non-Uniform Memory Access — a multi-socket architecture where local memory is faster to access than another socket’s memory.

What is a NUMA node?A memory bank physically attached to a specific CPU socket.

What is first-touch allocation?Placing a new memory page on the NUMA node of the core that first accesses it.

What risk does thread migration pose on NUMA systems?Moving a thread without its memory turns every access into a slower remote-node access.

1 / 4

Continue Learning