Transport & Auth
How MemKV moves bytes over RDMA and TCP, how it authenticates and encrypts data, and how a context block is offloaded.
MemKV uses the same authenticated wire format over two transports: RDMA and TCP. The full server on Linux always listens on both, and each client chooses which to use.
RDMA (DC + RC)
Data operations use DC (Dynamically Connected) transport on Mellanox mlx5 NICs that support DC.
In classic RC, every pair of peers needs its own queue pair (QP), so the number of QPs grows as O(N²) with the cluster.
DC replaces this with a shared pool of DCI (DC Initiator) QPs that can reach any DCT (DC Target) endpoint, so the number of QPs grows as O(N).
On hardware without DC support, MemKV falls back to RC (Reliable Connection) QPs automatically.
The DCI pool has a fixed size by default (see rdma.num_dcis in Configuration).
Under heavy fan-in, different workers can take turns on the same DCI.
Wire carriers
The server listens on TCP at the configured network.address (default 9900).
An RDMA client starts on that TCP connection: it sends Connect over TCP, because the RC QP does not exist yet.
Once Connect moves the RC QP to the ready-to-send (RTS) state, the client sends the control messages of single-key requests (Allocate, Lookup, Commit, Delete, Read, Write, Exists) as RC SEND/RECV on that connection's QP.
On NICs with DC, batched reads and writes send their small control messages over the client's TCP connection to the server instead, and the data still moves only by RDMA.
On NICs without DC, or with transport: rdma-rc, batches use the RC QP.
Bulk payloads move by RDMA WRITE and RDMA READ through the DCI/DCT pool, or over RC when DC is not available.
A client that does not use RDMA sends everything over the TCP connection.
TCP put, get, and delete requests and Exists carry their payloads inside the signed, length-prefixed frame. Larger values stream in chunks.
A client with no RDMA NIC, or one set to transport: tcp, never sets up a QP.
The client chooses its transport with MEMKV_TRANSPORT (or transport: in MEMKV_CONFIG):
autotries RDMA first. On the first RDMA failure, at startup or during a transfer, it switches to TCP for the life of the engine and logs a WARN message. This is the default on Linux.rdmais strict. The client fails at startup ifrdma_devicesis empty or the build is not for Linux, and RDMA failures during a transfer are returned as errors. Use it in production when RDMA must carry the data.rdma-rcis strict likerdma, but always uses RC queue pairs, even on NICs with DC.tcpskips RDMA. The client sends TCP traffic to the configured server address. This is the default on macOS.
The transport is the client's choice. The server has no setting to turn off either listener.
Topology vs storage mode
These are two independent choices:
- Topology is either distributed (several servers, each with its own NVMe drives; the shape behind the 97.4 GB/s results in Benchmarks) or co-located (one MemKV server on the inference host, common on GPU servers with NVMe next to the NIC).
- Storage mode is
direct,file, ormemory.directuses raw block devices and is the high-performance mode in either topology.filestores data in regular files through mmap, for developers, kind or CI clusters, Macs, and hosts with no raw drives to dedicate. Infilemode the host filesystem limits the bandwidth.memorykeeps data in RAM only, so it is lost on restart. Use it for development and tests.
macOS always runs in file mode over TCP, because the macOS build has no RDMA, JBOF, or hugepage support.
You can run the same shape on Linux with storage.mode: file and transport: tcp, but a Linux host with raw drives should use direct for full performance.
Authentication
Every wire message carries a timestamp and an HMAC-SHA256 tag over its header and timestamp.
Both ends use the same shared key: network.auth_key on the server, auth_key: on the client, or MEMKV_AUTH_KEY on either.
The allowed clock drift is ±60 s.
If a message's timestamp is outside that window or its MAC is wrong, the server replies with an InvalidRequest error and counts it in memkv_invalid_requests_total.
There is no unauthenticated mode: the engine refuses to start without a key.
Encryption
MemKV handles authentication and encryption separately, at different layers.
On the wire. The HMAC tag covers only the control header and its timestamp. It proves that the sender holds the shared key and rejects replays outside the drift window. It does not cover the payload, so it does not keep the data secret or show that someone changed it. MemKV adds no checksum of its own to TCP frames. TCP's checksum catches accidental corruption, not deliberate changes.
RDMA usually runs over a dedicated RoCE fabric, on a storage network that is physically isolated.
On the TCP path the KV data also travels unencrypted, and the TCP data plane does not support TLS.
Use TCP only on trusted networks, and keep it off links you do not control.
The tls_cert and tls_key settings apply only to the admin HTTP endpoint.
On the drive. Encryption at rest works with either transport.
Set crypto.enabled: true and put a 32-byte AES-256 master key in crypto.master_key_hex.
The storage layer then encrypts every sector with AES-256-GCM on write and decrypts it on read.
The encryption is recorded on the drives when they are initialized, so a set cannot switch it on or off later, and a wrong key is refused.
Offloading the cipher to a BlueField-3 DPU through DOCA is not supported yet: leave crypto.doca_device unset.
Context block offload flow
- Dynamo/KVBM picks context blocks to offload.
- NIXL calls the MemKV plugin with the client buffer address and rkey.
- The plugin sends a write request to the server. On a NIC with DC, a batch sends it over the client's TCP connection. On an RC-only NIC, or with
transport: rdma-rc, it uses the RC QP. - The server takes a DCI from the pool and uses RDMA READ to copy the data from client memory (DC transport).
- The server writes the data to NVMe through io_uring with O_DIRECT.
- On a lookup hit, the server reads the data from NVMe and uses RDMA WRITE through a DCI to send it back to the client.