Post

How RDMA moves bytes between machines

Start with what a network adapter does. Then follow an animated remote write and see how storage and model-serving software use RDMA.

How RDMA moves bytes between machines

A program on server A wants to copy a record into a buffer on server B. A buffer is a range of memory set aside to hold bytes. With a regular network socket, B’s program reads the incoming bytes into that buffer. With Remote Direct Memory Access (RDMA), B can authorize A to write to a particular buffer, and B’s network adapter can put the bytes there as they arrive.

To see why that matters, start with what a network adapter can do inside one computer.

A network adapter can move bytes on its own

A network interface card (NIC) is the hardware that sends and receives packets. It can be built into a machine or plugged in as a separate card. The central processing unit (CPU) runs your program and the operating system. Random access memory (RAM) holds working data, including the buffers your program uses.

When a device reads or writes local memory without the CPU copying the bytes itself, that’s Direct Memory Access (DMA). The software running on the CPU sets up the work. The device moves the bytes. Ordinary network adapters already use DMA. Linux device memory guide

DMA inside one computer
CPURuns the software
↓ Software sets up the transfer
Network adapterMoves the bytes
DMA
MemoryHolds the buffer

RDMA changes where incoming bytes land

On a typical Transmission Control Protocol (TCP) socket, the receiving adapter places packets in buffers managed by the operating system. The kernel, the core of the operating system, processes those packets. When the receiving program calls recv(), the kernel usually copies the requested bytes into the program’s buffer. TCP gives the program a byte stream, so the program also has to work out where each record begins and ends. TCP specification · Linux receive system calls

With an RDMA Write, the sending program names a destination in advance. The receiving adapter checks access and places the payload in that destination buffer. The kernel still helps set up the resources. The transfer can skip the usual per-message work in the kernel’s network stack and the copy into the receiving program. Linux userspace networking driver guide · RDMA protocol specification

Where the bytes go on server B
Typical TCP socket
  1. Network adapter
  2. Operating system buffer
  3. Program's buffer
RDMA Write
  1. Network adapter
  2. Places bytes directly
  3. Program's buffer

Follow one RDMA write

Say server A is copying a log record to server B. Each program registers its buffer with the RDMA driver before the transfer. Registration describes the memory range and its permitted uses to the adapter. B grants remote write access, then shares the destination address, its capacity, and a remote key, called rkey. The adapter uses the key to check the region’s bounds and permissions. A also has a local key, called lkey, for its own buffer. Linux memory registration manual

A submits the operation as a work request. A queue pair (QP) has one queue for outgoing instructions and one for receive requests. A completion queue (CQ) holds results that the program can check. RDMA programming manual · Linux completion queue manual

One record from A to B
  1. Prepare a buffer. B registers a free buffer and gives A its address and remote key. B also puts a receive request in its queue to accept a notification.
  2. Post the write. A tells its adapter where to read locally, how many bytes to copy, and where to place them on B.
  3. Move the bytes. A's adapter reads the buffer with DMA and sends the record. B's adapter checks the destination and writes the bytes into B's buffer.
  4. Check the results. A can reuse its source buffer after a successful local completion. B gets a receive completion with the buffer's identifier, so its program knows where to read.
  5. Save the record. B's program appends the record to its log and acknowledges it when the log is safely stored.

The example uses Write with Immediate. A attaches a 32-bit number that identifies the destination buffer. B’s adapter consumes the posted receive request to deliver that number in a completion. A plain Write leaves out that notification. The completion tells B that the bytes are ready in memory. B’s later acknowledgment tells A that the application has saved the record. Linux send and completion manuals · RDMA programming manual

Read, write, and send

The question to ask is who picks the buffer on the other machine.

Operation What it does Who picks the remote buffer?
RDMA Write Pushes bytes to another machine. The writer names the destination.
RDMA Read Pulls bytes into a local buffer. The reader names the source.
Send and Receive Delivers a message to a buffer the receiver has prepared. The receiver supplies the destination.

Read and Write are called one-sided because the remote program can authorize access ahead of time and leave the transfer to the adapters. Send and Receive are two-sided because the receiver supplies a receive request for each message. It can queue those requests in advance. RDMA programming manual

Which networks carry RDMA?

InfiniBand is a network built for workloads such as high-performance computing. RDMA over Converged Ethernet (RoCE) carries RDMA over Ethernet. Version 2, written RoCEv2, can cross Internet Protocol (IP) routers. Its packets are carried in User Datagram Protocol (UDP), and reliable RDMA connections have their own delivery and retry rules. The Internet Wide Area RDMA Protocol (iWARP) carries RDMA over TCP. Hardware and network configuration determine which transports are available. InfiniBand programming manual · RoCE guide · Microsoft RDMA transport overview · iWARP specification

Where you encounter RDMA

  • Windows file shares. Microsoft’s Server Message Block (SMB) Direct uses compatible adapters to move file data with less CPU work. This matters when a database or a virtual machine keeps its files on another server. Microsoft SMB Direct documentation
  • Networked block storage. Non-Volatile Memory Express (NVMe) over Fabrics lets a host access a remote drive as block storage. With its RDMA transport, read and write data move between the host’s buffers and the storage server over the network. NVMe over RDMA specification
  • Distributed model training. The NVIDIA Collective Communications Library (NCCL) helps graphics processing units (GPUs) combine results across machines. For example, workers can sum their gradients at each training step. NCCL can use InfiniBand or RoCE to exchange those arrays. NVIDIA collective operations · NCCL network transport documentation
  • Language model serving. vLLM is an open-source engine for serving large language models. One worker can process the prompt while a separate worker generates the answer. The second worker can use the NVIDIA Inference Xfer Library (NIXL) to pull the key-value (KV) cache, the attention data calculated for the prompt, over RDMA. With supported hardware, GPUDirect RDMA lets the adapters access GPU memory directly, avoiding a copy through each machine’s main memory. vLLM cache transfer design · NIXL project · GPUDirect documentation

RDMA is useful when moving data takes enough time or CPU capacity to matter, and the application can reuse registered buffers. It adds work too. Programs have to keep buffers valid while transfers are in flight, agree on when to reuse them, and handle failures. The network still has to carry every byte. For the log example, measure the time until B’s durable acknowledgment and the CPU time used to get there. A fast transfer can free CPU capacity even when storage still accounts for most of the wait.

This post is licensed under CC BY 4.0 by the author.