This post records how I built SPDK v24.09 from source on Debian 12, got it running, and hammered it with fio. It starts from the I/O path and the Reactor model, then covers deployment, verification, monitoring and what to watch out for before going live.

I actually ran the malloc bdev, NBD and NVMe-oF/TCP paths; section 4.5 has the test environment and raw numbers. NVMe passthrough requires binding the disk to VFIO, and my test environment has no disk I can pass through, so that part is steps only; production tuning and monitoring integration are also marked as recommendations and need validation in your own environment before going live.


Contents

  1. What Is SPDK
  2. Why Use SPDK
  3. Deploying SPDK on Debian 12
  4. Post-Deployment Verification
  5. Monitoring
  6. Upgrades and Rollback
  7. Production Best Practices
  8. Troubleshooting Guide
  9. Further Reading
  10. Appendix: Minimal Reproduction Script

1. What Is SPDK

SPDK (Storage Performance Development Kit) is a userspace storage development kit, originally started by Intel. It puts the NVMe driver, the block device abstraction (bdev), protocols such as NVMe-oF/iSCSI/vhost-user, and memory management in userspace; the core techniques are polling instead of interrupts, zero copy, and lock-free queues. The direct result is that the software overhead of a 4K random read drops to the microsecond level, at the cost of dedicating CPU cores.

Core capabilities at a glance:

Capability Description
Userspace NVMe driver Bypasses the kernel nvme driver and operates the PCIe BAR space directly to submit and complete I/O
bdev abstraction layer A unified block device interface supporting malloc / NVMe / AIO / Ceph RBD / RAID / Crypto / QoS and other backends, composable and stackable at runtime
Multi-protocol target NVMe-oF (TCP/RDMA), iSCSI, vhost-user, NBD and more; one process can expose several protocols at once
JSON-RPC control plane All runtime configuration goes through JSON-RPC over a Unix domain socket, which suits automated orchestration
Reactor thread model An event-driven framework built on DPDK EAL; each Reactor is bound to one CPU core, and the run-to-completion model avoids thread-switching overhead

1.1 Overall Architecture

graph TB
    subgraph Applications
        A1["spdk_tgt"]
        A2["nvmf_tgt"]
        A3["vhost"]
        A4["iscsi_tgt"]
        A5["Custom App"]
    end
    subgraph Control Plane
        B1["JSON-RPC Server
Unix Domain Socket"] B2["rpc.py / curl"] end subgraph SPDK Framework C1["Reactor / Thread Model"] C2["Event Framework"] C3["Poller Subsystem"] end subgraph Block Device Layer - bdev D1["malloc"] D2["NVMe bdev"] D3["AIO / uring"] D4["Ceph RBD"] D5["RAID"] D6["Crypto"] D7["QoS / Rate Limit"] end subgraph Transport Protocols E1["NVMe-oF/TCP"] E2["NVMe-oF/RDMA"] E3["iSCSI"] E4["vhost-user"] E5["NBD"] end subgraph Low-Level Drivers F1["SPDK NVMe Driver
User-Space PCIe"] F2["DPDK EAL"] F3["VFIO / UIO"] end subgraph Hardware G1["NVMe SSD"] G2["NIC - RDMA / TCP"] end B2 --> B1 B1 --> A1 B1 --> A2 B1 --> A3 B1 --> A4 B1 --> A5 A1 --> C1 A2 --> C1 A3 --> C1 A4 --> C1 A5 --> C1 C1 --> C2 C2 --> C3 C3 --> D1 C3 --> D2 C3 --> D3 C3 --> D4 C3 --> D5 C3 --> D6 C3 --> D7 D5 --> D2 D6 --> D2 D7 --> D2 D2 --> F1 F1 --> F2 F2 --> F3 F3 --> G1 A1 --> E5 A2 --> E1 A2 --> E2 A4 --> E3 A3 --> E4 E1 --> D1 E1 --> D2 E2 --> D2 E3 --> D2 E4 --> D2 E5 --> D1 E1 --> G2 E2 --> G2 E3 --> G2

Read the diagram from the bottom up: the hardware layer is the NVMe SSD and the NIC; SPDK’s userspace driver takes over the devices through DPDK and VFIO/UIO; the bdev layer unifies malloc, NVMe, AIO, RBD, RAID, Crypto and QoS backends into block devices; the Reactor handles the event loop and polling; at the top are the applications spdk_tgt, nvmf_tgt, vhost and iscsi_tgt, with JSON-RPC handling runtime configuration.

RAID, Crypto and QoS stack on top of other bdevs, which is why they’re drawn as arrows pointing at the NVMe bdev.

1.2 Traditional Kernel I/O Path vs SPDK I/O Path

SPDK’s performance comes from the difference between the two I/O paths:

graph TD
    subgraph Kernel I/O Path
        KA["Application
User Space"] -->|"syscall
context switch"| KB["VFS / Page Cache"] KB --> KC["Block Layer
I/O Scheduler / mq"] KC --> KD["NVMe Driver
Kernel Space"] KD -->|"MMIO doorbell"| KE["NVMe Hardware"] KE -.->|"completion IRQ"| KD end subgraph SPDK I/O Path SA["Application
User Space"] -->|"function call
no syscall"| SB["SPDK bdev API"] SB --> SC["SPDK NVMe Driver
User Space / Polling"] SC -->|"MMIO doorbell"| SE["NVMe Hardware"] SE -.->|"poll completion queue"| SC end

Key differences:

Dimension Kernel path SPDK path
System calls At least 1 syscall per I/O (read/write/io_submit) No syscalls, pure function calls
Interrupt handling Hardware interrupt on completion -> softirq -> wake the process Polling; Reactor threads keep checking completion queues
Data copy Usually through the page cache or a bounce buffer Zero copy; DMA reads/writes userspace memory (hugepages) directly
Context switches Frequent userspace <-> kernel switches The same userspace thread does the whole path, no switching
Lock contention The kernel block layer has multiple lock levels (blk-mq improved this) Lock-free design; each Reactor owns its queues and resources
CPU usage pattern Releases the CPU when idle (woken by interrupts) Polling threads keep the CPU core busy even with no I/O

The trade-off to keep in mind: SPDK’s polling model means the bound CPU cores stay at 100% even with no I/O requests. That’s reasonable for I/O-heavy workloads (trading CPU for latency), but with mixed or low-I/O workloads you need to evaluate the CPU budget carefully.

1.3 Reactor Thread Model

You need to understand the Reactor model before tuning:

graph LR
    subgraph CPU Core 0
        R0["Reactor 0
Main Reactor"] R0 --> P0A["Poller: NVMe I/O"] R0 --> P0B["Poller: JSON-RPC"] R0 --> P0C["Poller: NVMe-oF Acceptor"] end subgraph CPU Core 1 R1["Reactor 1"] R1 --> P1A["Poller: NVMe-oF
Poll Group 1"] R1 --> P1B["Poller: bdev I/O"] end subgraph CPU Core 2 R2["Reactor 2"] R2 --> P2A["Poller: NVMe-oF
Poll Group 2"] R2 --> P2B["Poller: bdev I/O"] end

Core concepts:

  • Reactor: an event loop thread bound to a single CPU core that never blocks, executing all registered Pollers in a run-to-completion model.
  • Poller: a callback registered on a Reactor; active pollers run every iteration (such as checking the NVMe completion queue), timed pollers run on a timer (such as collecting statistics).
  • SPDK Thread: a logical thread that can run on any Reactor. One Reactor can host several SPDK Threads.
  • Message Passing: Reactors pass messages through lock-free rings, avoiding lock contention on shared data structures.

The direct consequences of this model:

  1. Give SPDK N cores and it uses N Reactors to process I/O in parallel;
  2. I/O paths on different Reactors are fully isolated, with no lock contention;
  3. More cores isn’t always better; you need to match the actual I/O concurrency and the number of NVMe queues.

2. Why Use SPDK

2.1 Performance

Enterprise NVMe 4K random read latency is already around 5µs. Once a request goes through the kernel block layer, interrupts and context switches, the software overhead often exceeds the media itself. Here are typical magnitudes from public sources:

Metric Hardware capability Kernel NVMe driver (fio ioengine=libaio) SPDK (fio ioengine=spdk)
4K random read latency ~5 µs (media latency) ~12-15 µs ~6-8 µs
4K random read IOPS (single core) ~800K+ ~200-350K ~600-800K
4K random read IOPS (multi-core saturated) ~1.6M+ ~800K-1M (limited by interrupts/locks) ~1.5M+ (near line rate)
CPU cost per IOP - ~4000-6000 cycles ~1000-1500 cycles

These numbers are typical magnitudes from public references (based on enterprise NVMe SSDs such as Intel P5800X / Samsung PM9A3), not measurements from this environment. Actual values vary with hardware model, firmware version, kernel version, fio parameters and so on; after deployment, go by your own measurements.

2.2 Real-World Use Cases

SPDK itself is neither a filesystem nor an out-of-the-box storage product. It’s more like a set of data-plane building blocks: how to compose bdevs, which protocols to expose, how the upper layer connects — you decide all of it. These are the more common patterns in community and commercial products.

Scenario Typical approach What to watch out for
NVMe-oF storage disaggregation The storage node uses nvmf_tgt to expose local NVMe over TCP/RDMA; compute nodes connect with the kernel nvme connect and use it as a local disk The network sets the ceiling. 1Gb is only good for functional validation — the 24K IOPS in 4.5 is the example; production needs at least 25Gb, and the host should use an allowlist or TLS
Virtualization block storage backend SPDK’s vhost program hands virtio-blk/scsi queues to QEMU via vhost-user, so VM I/O doesn’t go through the host kernel block layer Configure hugepages and CPU pinning; the vhost-user socket lifetime must line up with QEMU’s
Local disk management for distributed storage engines Engines like DAOS use SPDK to manage NVMe directly, handing disks to the userspace I/O stack; SPDK’s own blobstore/blobfs can serve as the upper layer You have to change the storage engine’s I/O layer; it’s not just mounting a disk. Replication and HA are the upper layer’s job
Kubernetes persistent volumes spdk-csi exposes SPDK-managed volumes to nodes over NVMe-oF, and CSI handles attach and mount Nodes need nvme-tcp installed; plan the network and multipath ahead; suits high-performance stateful workloads
In-house data plane Write SPDK applications directly on the bdev API, then add QoS, RAID, crypto and other bdevs Highest development and operations cost; suits storage vendors or large in-house teams

When choosing, first decide what interface the upper layer needs: block devices for hosts or VMs, pick NVMe-oF; disks for QEMU, pick vhost-user; Kubernetes, pick CSI; only when changing the storage engine internals do you need to write a bdev application directly.

Some projects worth a look:

  • Ceph NVMe-oF Gateway: exposes Ceph RBD images to clients over NVMe-oF/TCP with SPDK.
  • DAOS: an HPC/AI storage engine that uses SPDK to access NVMe underneath.
  • SPDK CSI: connects SPDK volumes into Kubernetes.
  • SPDK vhost: the virtio backend for QEMU/KVM.

These cases are a poor fit for SPDK:

  • The application wants a POSIX filesystem, plain open/read/write. SPDK doesn’t provide those semantics.
  • I/O is sparse but CPUs are tight. Polling threads keep the cores occupied.
  • Only SATA/SAS HDDs. The hardware itself is the bottleneck, so SPDK gains little.
  • The team has no capacity to maintain userspace processes, hugepages, VFIO and CPU pinning. In that case, start with io_uring.

To decide whether to adopt it, ask three questions: is the current bottleneck I/O? Can you accept a few CPU cores being consumed by polling threads? Does the team have the capacity to maintain a userspace storage stack? If the first two are “yes” and you have some confidence on the third, consider SPDK.

2.3 Compared with io_uring

io_uring, the new asynchronous I/O interface introduced in Linux 5.x, also aims to reduce I/O path overhead, but its positioning is different:

Dimension SPDK io_uring
Execution space Userspace, fully bypassing the kernel Submitted from userspace, executed by the kernel
Device binding Requires unbinding the device from the kernel driver (VFIO/UIO) No unbinding; the kernel driver keeps working
Latency floor Lower (no syscalls, no interrupts) Slightly higher than SPDK, but far lower than libaio
Ecosystem compatibility A separate programming model, incompatible with POSIX I/O Compatible with existing kernel block devices and filesystems
Operational complexity High (hugepages, VFIO, dedicated CPU cores) Low (native kernel support, no extra configuration)
Typical users Storage vendors, SDS engines, NVMe-oF targets General high-performance applications, databases (e.g. the io_uring build of RocksDB)

On selection: if an existing application runs on a kernel filesystem or block device and you want more performance with few code changes, start with io_uring; if you’re building an NVMe-oF target, a vhost-user backend, or want to control the whole data plane yourself, look at SPDK. They’re not replacements for each other, and many storage systems use both.

3. Deploying SPDK on Debian 12

This section uses Debian 12 (bookworm, x86_64) as an example and gives reproducible from-scratch deployment steps. It assumes bash and sudo.

Note: the malloc bdev, NBD and NVMe-oF/TCP loopback paths in this and section 4 can be reproduced in a Debian 12 VM with no NVMe hardware; VFIO binding and NVMe passthrough need real devices and are out of scope here.

3.1 Environment and Prerequisites

Hardware requirements:

Item Minimum Production recommendation
CPU architecture x86_64 (SSE4.2 support) NUMA-capable multi-core Xeon / EPYC
Memory 4 GB (including 2 GB hugepages) Plan by bdev count and connection count; at least 16 GB
Disk Any (validate with malloc bdev) NVMe SSD (VFIO-capable)
IOMMU Optional Recommended for production (Intel VT-d / AMD-Vi)
Network Optional Gigabit or faster NIC for NVMe-oF/TCP; RoCE/IB NIC for RDMA
# Check distribution and kernel version
cat /etc/os-release | grep -E 'PRETTY_NAME|VERSION_ID'
uname -r

# Check whether the CPU supports SSE4.2 (required by DPDK)
grep -o 'sse4_2' /proc/cpuinfo | head -1

# Check whether IOMMU is enabled (optional)
dmesg | grep -i -E 'DMAR|IOMMU' | head -5

# Check existing NVMe devices (optional)
lspci -nn | grep -i 'Non-Volatile memory'
nvme list 2>/dev/null || echo "No NVMe devices found, or nvme-cli is not installed"

3.2 Installing Build Dependencies

Pick one of the two approaches, depending on your environment:

Option one: install the minimal dependency set by hand (suits offline preparation or environments with strictly controlled package sources)

sudo apt update
sudo apt install -y \
    git build-essential meson ninja-build pkg-config \
    python3 python3-venv python3-pip python3-pyelftools \
    libnuma-dev libssl-dev libaio-dev libfuse3-dev \
    uuid-dev libncurses-dev libcunit1-dev \
    autoconf automake libtool \
    jq curl fio nvme-cli \
    nasm

Purpose of each dependency:

Package Purpose
meson / ninja-build Build the DPDK submodule; SPDK’s top level still uses ./configure + make
libnuma-dev NUMA-aware memory allocation
libssl-dev TLS support (NVMe-oF/TCP with TLS)
libaio-dev AIO bdev backend
libfuse3-dev NVMe CUSE character device and blobfs FUSE mounts
python3-pyelftools DPDK build dependency
autoconf / automake / libtool Building the bundled ISA-L and ISA-L-crypto submodules; autogen.sh needs autoreconf
libcunit1-dev CUnit headers, needed to build the bundled unit tests (ut)
nasm Assembling ISA-L (storage acceleration library)
fio / nvme-cli Performance testing and NVMe management tools
uuid-dev / libncurses-dev UUID generation / the spdk_top TUI

scripts/pkgdep.sh installs all of these in one go; when installing by hand, libfuse3-dev, autoconf/automake/libtool, meson/ninja-build and libcunit1-dev are the easiest to miss, and missing any one of them breaks configure or make.

Option two: use SPDK’s own script to install everything (recommended for networked environments)

# Clone the source first (see 3.3), then run
sudo scripts/pkgdep.sh

The script detects the distribution from /etc/os-release and installs all known dependencies, including optional components such as RDMA, iSCSI and FUSE.

If you’ll use RDMA (RoCE v2) later, additionally make sure these are installed: sudo apt install -y rdma-core libibverbs-dev librdmacm-dev

3.3 Fetching and Building SPDK (pinned tag, reproducible)

Pinning the tag ensures every build gets the same code and avoids HEAD drift.

cd /opt
sudo git clone https://github.com/spdk/spdk.git
sudo chown -R $(whoami):$(whoami) /opt/spdk
cd /opt/spdk

# Pin to a stable release
git checkout v24.09
git submodule update --init --recursive

For production, keep the source and build output in /opt/spdk rather than $HOME, which makes multi-user access and permission management easier.

# SPDK's top level builds with configure + make
./configure --with-vhost --with-virtio --with-nvme-cuse
make -j$(nproc)

SPDK v24.09’s top level still uses ./configure + make and has no meson.build. meson/ninja are the build tools for the DPDK submodule, invoked by make automatically, which is why they’re in the dependency list; don’t follow some docs and run meson setup build — there’s no such build definition here.

# Verify the key binaries were built
ls -la build/bin/spdk_tgt build/bin/nvmf_tgt build/examples/hello_world

Offline build option:

For production environments without network access, complete these steps on a build machine with network access and then package and transfer the result:

# On the networked machine
cd /opt/spdk && git checkout v24.09
git submodule update --init --recursive
# Package the whole /opt/spdk directory (including submodules)
tar czf spdk-v24.09-full.tar.gz -C /opt spdk/

# Transfer to the offline target, unpack and build there

3.4 Configuring Hugepages

SPDK uses hugepages through DPDK for DMA buffers and internal data structures; this is a hard prerequisite.

Capacity planning:

Scenario Recommended hugepages (2MB pages) Total
Functional validation (malloc bdev) 1024 pages 2 GB
Single NVMe + NVMe-oF target 2048 pages 4 GB
Multiple NVMe + high connection count 4096+ pages 8+ GB

The actual cost depends on I/O size, queue depth, connection count and shared buffer configuration; you can’t estimate it from bdev count alone. 1-2 GB is enough for functional validation; with many connections and deep queues, -s needs to grow accordingly. Before going live, check the headroom with spdk_top, bdev_get_iostat and HugePages_Free, then adjust.

Temporary (for testing):

# Show current hugepage status
grep -i huge /proc/meminfo

# Set 1024 2MB hugepages (about 2GB)
sudo sysctl -w vm.nr_hugepages=1024

# Make sure hugetlbfs is mounted
sudo mkdir -p /dev/hugepages
sudo mount -t hugetlbfs nodev /dev/hugepages 2>/dev/null || true

# Verify
grep HugePages_ /proc/meminfo

vm.nr_hugepages is a request; how much the kernel can actually allocate depends on available memory and fragmentation. On a 3 GB VM, the first write of 1024 only got HugePages_Total to 454 (908 MB), and spdk_tgt -s 1024 then reported EAL: Not enough memory available! Requested: 1024MB, available: 908MB. Run sync, then echo 3 | sudo tee /proc/sys/vm/drop_caches, then set vm.nr_hugepages again to get 1024 pages. In production, reserve memory per the capacity plan above.

Persistent (production):

# Write the sysctl configuration
cat <<'EOF' | sudo tee /etc/sysctl.d/60-spdk-hugepages.conf
# SPDK hugepage configuration
vm.nr_hugepages = 2048
EOF

# Write fstab so hugetlbfs mounts at boot
grep -q hugetlbfs /etc/fstab || \
    echo 'nodev /dev/hugepages hugetlbfs defaults,mode=1770,gid=0 0 0' | sudo tee -a /etc/fstab

sudo sysctl -p /etc/sysctl.d/60-spdk-hugepages.conf
sudo mkdir -p /dev/hugepages
sudo mount -a

# Verify
grep HugePages_ /proc/meminfo

NUMA-aware hugepage allocation (multi-socket servers):

On servers with multiple NUMA nodes, allocate hugepages on the NUMA node where the NVMe device sits, to avoid cross-node memory access:

# Show the NUMA node of the NVMe device
cat /sys/bus/pci/devices/0000:5e:00.0/numa_node

# Allocate hugepages on specific nodes (example: 1024 pages on node 0, 1024 on node 1)
echo 1024 | sudo tee /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 1024 | sudo tee /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages

1G hugepages usually have to be reserved in the kernel boot parameters (hugepagesz=1G default_hugepagesz=1G hugepages=N) and can’t be grown on demand like 2MB pages. Workloads sensitive to TLB misses can use 1G pages, but plan the memory in advance.

3.5 VFIO Device Binding (optional, NVMe passthrough)

SPDK’s userspace driver needs PCIe resource access to the NVMe device through VFIO (recommended) or UIO.

Pure malloc bdev functional validation can skip this section.

Step one: enable IOMMU

# Intel CPU
sudo mkdir -p /etc/default/grub.d
echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT intel_iommu=on iommu=pt"' \
    | sudo tee /etc/default/grub.d/90-iommu.cfg

# AMD CPU (pick one)
# echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT amd_iommu=on iommu=pt"' \
#     | sudo tee /etc/default/grub.d/90-iommu.cfg

sudo update-grub
sudo reboot

Verify after reboot:

dmesg | grep -i -E 'DMAR|IOMMU' | head -5
# You should see output like "DMAR: IOMMU enabled"

Step two: bind the NVMe device

cd /opt/spdk

# Show current NVMe devices and their driver binding
sudo scripts/setup.sh status

# Bind (binds all NVMe devices to VFIO; note: this removes kernel nvme driver access)
sudo HUGEMEM=4096 scripts/setup.sh

# Confirm the binding again
sudo scripts/setup.sh status

Production warning: scripts/setup.sh binds all NVMe devices by default. If the system disk is NVMe, you must exclude it with the PCI_BLOCKED environment variable:

# Exclude the system disk (assume it is NVMe at PCI address 0000:01:00.0; confirm with lspci)
sudo PCI_BLOCKED="0000:01:00.0" HUGEMEM=4096 scripts/setup.sh

Return devices to the kernel driver:

sudo scripts/setup.sh reset

3.6 Starting spdk_tgt and Managing It over JSON-RPC

spdk_tgt is SPDK’s general-purpose target process; once started, bdevs, transports and subsystems are configured dynamically over JSON-RPC.

Basic startup:

cd /opt/spdk

# Foreground start (for debugging; logs also go to a file; Ctrl+C to stop)
sudo build/bin/spdk_tgt -m 0x3 -s 2048 -r /var/tmp/spdk.sock 2>&1 | tee /tmp/spdk_tgt.log

# Parameters:
#   -m 0x3     : CPU core mask, 0x3 = cores 0 and 1 (binary 11)
#   -s 2048    : SPDK memory size (backed by hugepages), in MB
#   -r <path>  : JSON-RPC Unix socket path

Verify the process is ready (in another terminal):

# Check the process
pgrep -a spdk_tgt

# Query loaded subsystems
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock framework_get_subsystems | jq '.[].subsystem'

# Query the Reactor list (confirm core binding)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock framework_get_reactors | jq '.reactors[] | {core: .lcore, busy: .busy, idle: .idle}'

3.7 Running as a systemd Service (production)

Production shouldn’t run the process in the background with &; manage it with systemd:

sudo cat > /etc/systemd/system/spdk-tgt.service <<'EOF'
[Unit]
Description=SPDK Target Daemon
After=network.target
Wants=network.target

[Service]
Type=simple
# Adjust the core mask to the actual NUMA topology
ExecStartPre=/sbin/modprobe vfio-pci
ExecStart=/opt/spdk/build/bin/spdk_tgt \
    -m 0x3 \
    -s 4096 \
    -r /var/tmp/spdk.sock \
    --wait-for-rpc
ExecStartPost=/bin/sleep 1
ExecStartPost=/opt/spdk/scripts/rpc.py -s /var/tmp/spdk.sock framework_start_init
ExecStartPost=/opt/spdk/conf/init-bdevs.sh
# Graceful stop
ExecStop=/opt/spdk/scripts/rpc.py -s /var/tmp/spdk.sock spdk_kill_instance SIGTERM
TimeoutStopSec=30
Restart=on-failure
RestartSec=5
# Hardening
LimitMEMLOCK=infinity
LimitNOFILE=65536
LimitCORE=infinity

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now spdk-tgt
sudo systemctl status spdk-tgt

--wait-for-rpc makes the process stop before initialization and wait for framework_start_init before starting subsystems. bdev creation must come after framework_start_init because the bdev RPCs depend on the bdev subsystem being initialized; the ExecStartPost lines above are ordered accordingly.

The companion initialization script (called by ExecStartPost above):

#!/usr/bin/env bash
# /opt/spdk/conf/init-bdevs.sh
# Create the required bdevs and subsystems over JSON-RPC after startup

set -euo pipefail

RPC="/opt/spdk/scripts/rpc.py -s /var/tmp/spdk.sock"

# Example: create a malloc bdev for testing (1024 MB, block size 4096)
$RPC bdev_malloc_create -b Malloc0 1024 4096

# Example: create an NVMe-oF/TCP transport
$RPC nvmf_create_transport -t TCP -u 8192 -m 8 -c 4096

echo "SPDK bdev initialization complete."

Remember to sudo chmod +x /opt/spdk/conf/init-bdevs.sh, otherwise systemd’s ExecStartPost reports permission denied. This example script isn’t idempotent: after a process restart, the bdev names collide, so clean up first or create on demand; in production, write the initialization script for your actual topology.

4. Post-Deployment Verification

4.1 to 4.4 are four verification paths from low to high, covering different hardware; 4.5 and 4.6 give measured numbers from a two-VM Homelab and the configuration for going from malloc bdev to real NVMe.

4.1 Simplest Check: malloc bdev + NBD + fio

This is an end-to-end verification that needs no special hardware: create a memory block device through SPDK, map it to a standard block device through the NBD (Network Block Device) kernel module, then test with fio.

The commands below assume spdk_tgt from 3.6 is already running. For malloc/NBD validation only, you can start spdk_tgt with -u (--no-pci) to skip PCI probing; don’t add it when attaching NVMe devices.

graph LR
    A["fio"] -->|"/dev/nbd0"| B["NBD
Kernel Module"] B -->|"NBD socket"| C["SPDK bdev
Malloc0"] C --> D["Hugepage Memory
User Space"]
cd /opt/spdk

# 1) Create a 1 GiB malloc bdev (block_size = 4096)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_create -b Malloc0 1024 4096

# 2) Load the NBD kernel module (allow up to 16 nbd devices)
sudo modprobe nbd nbds_max=16

# 3) Map the bdev to /dev/nbd0
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_start_disk Malloc0 /dev/nbd0

# 4) Confirm the device is ready
lsblk | grep nbd0

# 5) fio benchmark: 4K random read/write mix, queue depth 32
sudo fio --name=spdk-malloc-verify \
    --filename=/dev/nbd0 \
    --ioengine=libaio \
    --direct=1 \
    --rw=randrw \
    --rwmixread=70 \
    --bs=4k \
    --iodepth=32 \
    --numjobs=1 \
    --time_based \
    --runtime=15 \
    --group_reporting

# 6) Check I/O statistics on the SPDK side
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_get_iostat -b Malloc0 | jq

# 7) Clean up
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_stop_disk /dev/nbd0
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_delete Malloc0

Before nbd_stop_disk, make sure no process is still using /dev/nbd0 (fio has exited, no filesystem mounted). sudo lsof /dev/nbd0 checks this.

The NBD path goes through the kernel block layer, so the fio numbers here only confirm that the SPDK process, the bdev and the mapping all work; they don’t represent SPDK’s data plane performance. I ran the commands above for 15 seconds in my test environment and got 38.4K IOPS read and 16.5K IOPS write, average clat about 574µs; more measurements in 4.5.

4.2 NVMe Passthrough Check (after 3.5 VFIO binding)

This needs real NVMe devices and VFIO binding. My test environment has no NVMe I can pass through, so this part is steps only.

hello_world talks to the device directly through SPDK’s userspace NVMe driver and doesn’t depend on the spdk_tgt process:

cd /opt/spdk

# Write a string to the NVMe device and read it back
sudo build/examples/hello_world

Expected output should include:

  • NVMe controller and namespace information probed by SPDK
  • A confirmation that “Hello world!\n” was written and read back identically

To see device enumeration and bdev names, take over the controller with spdk_tgt:

sudo build/bin/spdk_tgt -m 0x3 -s 2048 -r /var/tmp/spdk.sock &
sleep 2
RPC="sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock"
$RPC bdev_nvme_attach_controller -b Nvme0 -t pcie -a 0000:5e:00.0
$RPC bdev_get_bdevs | jq -r '.[].name'

For load testing you can use SPDK’s fio plugin or bdevperf. The fio plugin isn’t built by default; prepare the fio source, then re-run configure and make with --with-fio=/path/to/fio, and the plugin appears under build/fio/. bdevperf is SPDK’s own bdev stress tool; see examples/bdev/bdevperf/.

v24.09’s examples/nvme/ doesn’t have the perf and identify examples; build/examples/perf and build/examples/identify don’t exist. Don’t copy those two commands from older docs.

4.3 NVMe-oF/TCP Loopback Check

An end-to-end check of exposing an NVMe-oF target and connecting an initiator on the same host:

graph LR
    subgraph Host - Same Machine
        A["nvme connect
Kernel Initiator"] -->|"TCP 127.0.0.1:4420"| B["nvmf_tgt
SPDK NVMe-oF Target"] B --> C["bdev: Malloc0
1 GiB"] A -.->|"/dev/nvmeXn1"| D["fio"] end
cd /opt/spdk

# 1) Stop spdk_tgt (if running) and start nvmf_tgt
sudo pkill spdk_tgt 2>/dev/null; sleep 1
sudo build/bin/nvmf_tgt -m 0x3 -s 2048 -r /var/tmp/spdk.sock &
sleep 2

# 2) Create a TCP transport
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_create_transport \
    -t TCP \
    -u 8192 \
    -m 8 \
    -c 4096

# 3) Create a malloc bdev
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_create -b Malloc0 1024 4096

# 4) Create an NVMe-oF subsystem (the NQN must be globally unique)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_create_subsystem \
    nqn.2025-10.io.spdk:cnode1 \
    -a -s SPDK00000001

# 5) Attach the bdev to the subsystem as a namespace
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_subsystem_add_ns \
    nqn.2025-10.io.spdk:cnode1 Malloc0

# 6) Add a TCP listener
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_subsystem_add_listener \
    nqn.2025-10.io.spdk:cnode1 \
    -t tcp -a 127.0.0.1 -s 4420

# 7) Kernel initiator side: discover and connect
sudo modprobe nvme-tcp
sudo nvme discover -t tcp -a 127.0.0.1 -s 4420
sudo nvme connect -t tcp -n nqn.2025-10.io.spdk:cnode1 -a 127.0.0.1 -s 4420

# 8) Confirm the new device appears
sleep 1
sudo nvme list
ls -la /dev/nvme*n* 2>/dev/null

# 9) fio verification
NVME_DEV=$(ls /dev/nvme*n1 2>/dev/null | tail -1)
if [ -n "$NVME_DEV" ]; then
    sudo fio --name=nvmeof-tcp-verify \
        --filename="$NVME_DEV" \
        --ioengine=libaio \
        --direct=1 \
        --rw=randread \
        --bs=4k \
        --iodepth=32 \
        --numjobs=1 \
        --time_based \
        --runtime=10 \
        --group_reporting
fi

# 10) Clean up (order matters)
sudo nvme disconnect -n nqn.2025-10.io.spdk:cnode1
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_delete_subsystem nqn.2025-10.io.spdk:cnode1
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_delete Malloc0

When testing across hosts, replace 127.0.0.1 in the commands with the target’s actual IP, and write the listener with that IP too. In v24.09, when the listener is written as 0.0.0.0, another machine connecting gets rejected by access control with does not allow host ... to connect at this address; I hit this pitfall in testing, details in 4.5.

4.4 Multi-Layer bdev Topology (RAID + QoS)

This section uses spdk_tgt. If you just did 4.3, stop nvmf_tgt first, then start spdk_tgt per 3.6 (you can add -u to skip PCI).

One of the SPDK bdev layer’s core capabilities is stackable composition. The example below builds a RAID0 across two malloc bdevs, then applies a QoS rate limit to the RAID device:

graph TB
    A["NBD /dev/nbd0
fio entry point"] --> B["bdev: QoS Layer
IOPS Limit: 50000"] B --> C["bdev: Raid0
Strip Size: 64K"] C --> D1["bdev: Malloc0
512 MiB"] C --> D2["bdev: Malloc1
512 MiB"]
cd /opt/spdk

# 1) Create two malloc bdevs
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_create -b Malloc0 512 4096
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_create -b Malloc1 512 4096

# 2) Create a RAID0 (strip size 64K)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_raid_create \
    -n Raid0 -z 64 -r 0 -b "Malloc0 Malloc1"

# 3) Set QoS on Raid0 (cap combined read/write at 50000 IOPS)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_set_qos_limit \
    Raid0 --rw-ios-per-sec 50000

# 4) Map it to NBD for verification
sudo modprobe nbd nbds_max=16
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_start_disk Raid0 /dev/nbd0

# 5) fio verification - check whether IOPS is capped around 50000
sudo fio --name=raid0-qos \
    --filename=/dev/nbd0 \
    --ioengine=libaio \
    --direct=1 \
    --rw=randread \
    --bs=4k \
    --iodepth=64 \
    --numjobs=1 \
    --time_based \
    --runtime=10 \
    --group_reporting

# 6) Clean up
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_stop_disk /dev/nbd0
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_raid_delete Raid0
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_delete Malloc0
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_delete Malloc1

Measured (2 vCPU VM, NBD entry): with the limit at 20000, fio read 19.9K IOPS and QoS worked; with the limit at 50000 it only read 44.6K, because this VM’s NBD path can’t reach 50K in the first place, so QoS wasn’t the bottleneck. Before tuning QoS, establish how fast the backend can go with an unlimited baseline.

4.5 Homelab Measurements: Local NBD and Cross-Host NVMe-oF

The previous sections are procedures; this section has real numbers. The test environment is a PVE 9.2 cluster, with two Debian 12 VMs on two physical nodes, connected by a 1Gb link:

Item Target Initiator
PVE node infra-node1 infra-node3
vCPU / memory 2 / 3072 MB 2 / 1536 MB
VM disk virtio disk on Ceph Same
Network virtio-net, physical port 1Gb/s Same
SPDK v24.09 (DPDK 24.03.0) Kernel nvme-tcp client
Test backend malloc bdev, 512 MiB —

Neither VM has NVMe passthrough. malloc bdev data lives in SPDK’s hugepage memory, so what’s measured below is the NBD path and the NVMe/TCP stack, not NVMe media performance.

First measure the network ceiling: iperf3 single stream for 10 seconds, 889 Mbits/s sender, 886 Mbits/s receiver.

Local malloc + NBD

spdk_tgt -m 0x1 -s 1024 -u, 512 MiB malloc bdev mapped to /dev/nbd0, fio 4K random read, QD128, 30 seconds per round with 5 seconds warmup, 3 rounds:

Round IOPS Bandwidth Average latency p99
1 56,045 219 MiB/s 2.27 ms 6.32 ms
2 63,305 247 MiB/s 2.01 ms 4.75 ms
3 51,567 201 MiB/s 2.47 ms 8.36 ms

The median is 56,045 IOPS, 219 MiB/s, average latency 2.27 ms, p99 6.32 ms, with IOPS ranging from 51,567 to 63,305 across the three rounds. The variance relates to the VMs sharing CPUs and NBD’s single queue. This magnitude only shows that the SPDK process, bdev and NBD mapping work; it can’t be used to judge SPDK’s IOPS. For data plane performance, use the NVMe passthrough in 4.2, or drive the bdev directly with fio’s SPDK ioengine.

Cross-host NVMe-oF/TCP

The target runs nvmf_tgt -m 0x1 -s 1024 -u and exposes the same 512 MiB malloc bdev over TCP; the initiator connects with the kernel nvme connect and runs the same 4K random read QD128 on /dev/nvme0n1, also 3 rounds:

Round IOPS Bandwidth Average latency p99
1 24,634 96.2 MiB/s 5.16 ms 10.29 ms
2 24,726 96.6 MiB/s 5.14 ms 9.90 ms
3 24,187 94.5 MiB/s 5.26 ms 11.86 ms

The median is 24,634 IOPS, 96.2 MiB/s, about 807 Mbits/s, which is 91% of the iperf3 receiver bandwidth. The bottleneck is the 1Gb link; the remaining ~9% is NVMe/TCP and TCP/IP overhead. Average latency rises from the 2 ms range of local NBD to 5 ms, mostly from network round trips and queueing; these numbers don’t represent NVMe-oF latency on 10Gb/25Gb networks or RDMA.

One access-control pitfall

If the target’s listener is written as -a 0.0.0.0, when an initiator connects from another machine, v24.09’s spdk_nvmf_subsystem_listener_allowed compares the connection’s actual address with the listener address, the comparison fails, and the target log reports:

Subsystem 'nqn.2025-10.io.spdk:cnode1' does not allow host 'nqn...' to connect at this address.

This time the subsystem had -a (allow any host), so it wasn’t the host NQN being rejected; the listener address didn’t match. Changing the listener to the target’s specific IP (in the example, 10.0.0.10) lets it connect. The loopback test uses 127.0.0.1 on both sides, so it doesn’t hit this.

On my test machine, running the loopback commands above with 4K random read, QD32, 10 seconds, I got 47.1K IOPS with average clat 659µs. Loopback doesn’t cross a physical network, so these numbers only confirm the target and initiator configuration; see 4.5 for cross-host data.

This test is the minimal validation for the storage disaggregation scenario. Swap the malloc bdev for real NVMe and the 1Gb link for 25/100Gb, and you get the shape described in the next section.

4.6 From malloc to Real NVMe: Minimal Config for a Storage Node

4.5 used a malloc bdev in place of a real disk. In production you swap the bdev for NVMe; the topology stays the same:

graph LR
    subgraph Compute Node
        A["Application / filesystem"]
        B["Kernel nvme-tcp initiator"]
    end
    subgraph Network
        C["25/100Gb TCP"]
    end
    subgraph Storage Node
        D["SPDK nvmf_tgt"]
        E["bdev: Nvme0n1"]
        F["NVMe SSD"]
    end
    A --> B
    B -->|"NVMe-oF/TCP"| C
    C --> D
    D --> E
    E --> F

This test environment has no NVMe I can pass through, so the NVMe bdev part below only checks RPC syntax and hasn’t been run on a real disk. Before production, walk through it with a disk whose data you can lose.

On the storage node, bind NVMe to VFIO first (see 3.5), then start nvmf_tgt:

cd /opt/spdk
sudo build/bin/nvmf_tgt -m 0x3 -s 4096 -r /var/tmp/spdk.sock &
sleep 2
RPC="sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock"

# 1) Create a TCP transport
$RPC nvmf_create_transport -t TCP -u 8192 -m 8 -c 4096

# 2) Take over the NVMe controller (-a is the PCI address; confirm with lspci)
$RPC bdev_nvme_attach_controller -b Nvme0 -t pcie -a 0000:5e:00.0

# 3) Confirm the namespace bdev appears, usually Nvme0n1
$RPC bdev_get_bdevs | jq -r '.[].name'

When creating the subsystem, don’t use -a; add the compute node’s host NQN to the allowlist:

# On the compute node, get the host NQN and note the output string
nvme show-hostnqn
# Example output: nqn.2014-08.org.nvmexpress:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

# On the storage node
RPC="sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock"
HOSTNQN="nqn.2014-08.org.nvmexpress:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
SUB=nqn.2025-10.io.example:storage0
$RPC nvmf_create_subsystem "$SUB" -s SPDK00000000000001
$RPC nvmf_subsystem_add_host "$SUB" "$HOSTNQN"
$RPC nvmf_subsystem_add_ns "$SUB" Nvme0n1
$RPC nvmf_subsystem_add_listener "$SUB" -t tcp -a 10.0.0.10 -s 4420

The compute node connects:

sudo modprobe nvme-tcp
sudo nvme discover -t tcp -a 10.0.0.10 -s 4420
sudo nvme connect -t tcp -n nqn.2025-10.io.example:storage0 -a 10.0.0.10 -s 4420
nvme list-subsys
lsblk

After that, use it like a local block device: mkfs, mount, or hand it straight to a database or storage engine. Before going live, confirm several things:

  • Network: 1Gb is only good for functional validation; the 24K IOPS in 4.5 is the 1Gb ceiling. To saturate NVMe you need at least 25Gb, ideally 100Gb.
  • Multipath: the kernel NVMe stack has built-in multipath and can connect to several listeners or ports on the same target. SPDK is only a target and does no replication; if the target dies, it dies. HA belongs in the upper layer.
  • Security: in production use a host allowlist, not -a; pin the initiator’s /etc/nvme/hostnqn and put it under configuration management, otherwise a reinstall changes the NQN and it can’t connect. If you need encryption, configure a PSK for the host and add --secure-channel to the listener.
  • Monitoring: feed bdev_get_iostat, nvmf_get_stats and spdk_top into Prometheus, and watch at least latency, queue depth and hugepage headroom.

5. Monitoring

SPDK ships a JSON-RPC statistics interface and spdk_top. DPDK’s telemetry is off by default when SPDK starts (--no-telemetry is in the EAL arguments), so monitoring goes mainly through JSON-RPC. In production you can feed these metrics into Prometheus + Grafana.

5.1 Monitoring Architecture Overview

graph LR
    subgraph SPDK Process
        A["spdk_tgt / nvmf_tgt"]
        B["JSON-RPC
/var/tmp/spdk.sock"] end subgraph Collection Layer D["spdk_exporter.sh
cron / systemd timer"] E["spdk_top
Interactive TUI"] end subgraph Monitoring Stack F["node_exporter
textfile collector"] G["Prometheus"] H["Grafana"] I["AlertManager"] end A --> B B --> D B --> E D -->|"write .prom file"| F F --> G G --> H G --> I

5.2 Querying Statistics over JSON-RPC

# bdev layer I/O statistics (the most common)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_get_iostat | jq

# Output structure (key fields):
# {
#   "tick_rate": 2200000000,          <- CPU TSC frequency
#   "ticks": 123456789,               <- current tick
#   "bdevs": [{
#     "name": "Malloc0",
#     "bytes_read": 1048576,
#     "bytes_written": 2097152,
#     "num_read_ops": 256,
#     "num_write_ops": 512,
#     "read_latency_ticks": 12345,    <- cumulative latency in ticks; divide by num_read_ops and convert
#     "write_latency_ticks": 23456,
#     ...
#   }]
# }

# NVMe-oF subsystem connection information
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_get_stats | jq

# Reactor thread load
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock framework_get_reactors | jq

Average latency conversion: latency_us = read_latency_ticks / num_read_ops / tick_rate * 1000000. read_latency_ticks is cumulative, not the latency of a single I/O.

5.3 Prometheus Integration (textfile collector)

The exporter below is a template; this environment isn’t wired to a real Prometheus/node_exporter, so confirm metric names and the collection path in a test environment first.

sudo cat > /usr/local/bin/spdk_exporter.sh <<'SCRIPT'
#!/usr/bin/env bash
# SPDK Prometheus Exporter - textfile collector
# Writes a .prom file on each run for node_exporter to collect

set -euo pipefail

SOCK="/var/tmp/spdk.sock"
RPC="/opt/spdk/scripts/rpc.py -s $SOCK"
OUT="/var/lib/node_exporter/textfile_collector/spdk.prom"
TMP=$(mktemp)

# Check whether the SPDK process is alive
if ! $RPC framework_get_reactors >/dev/null 2>&1; then
    echo '# SPDK process not running' > "$TMP"
    echo 'spdk_up 0' >> "$TMP"
    mv "$TMP" "$OUT"
    exit 0
fi

echo 'spdk_up 1' > "$TMP"

# bdev I/O statistics
IOSTAT=$($RPC bdev_get_iostat 2>/dev/null || echo '{}')
TICK_RATE=$(echo "$IOSTAT" | jq -r '.tick_rate // 1')

echo "$IOSTAT" | jq -r --argjson tr "$TICK_RATE" '
    .bdevs[]? |
    "spdk_bdev_bytes_read{bdev=\"\(.name)\"} \(.bytes_read // 0)",
    "spdk_bdev_bytes_written{bdev=\"\(.name)\"} \(.bytes_written // 0)",
    "spdk_bdev_read_ops_total{bdev=\"\(.name)\"} \(.num_read_ops // 0)",
    "spdk_bdev_write_ops_total{bdev=\"\(.name)\"} \(.num_write_ops // 0)",
    "spdk_bdev_read_latency_us{bdev=\"\(.name)\"} \((if .num_read_ops > 0 then (.read_latency_ticks / .num_read_ops / $tr * 1000000) else 0 end))",
    "spdk_bdev_write_latency_us{bdev=\"\(.name)\"} \((if .num_write_ops > 0 then (.write_latency_ticks / .num_write_ops / $tr * 1000000) else 0 end))"
' >> "$TMP"

# Reactor load statistics
$RPC framework_get_reactors 2>/dev/null | jq -r '
    .reactors[]? |
    "spdk_reactor_busy_ticks{core=\"\(.lcore)\"} \(.busy // 0)",
    "spdk_reactor_idle_ticks{core=\"\(.lcore)\"} \(.idle // 0)"
' >> "$TMP"

mv "$TMP" "$OUT"
chmod 0644 "$OUT"
SCRIPT

sudo chmod +x /usr/local/bin/spdk_exporter.sh
sudo mkdir -p /var/lib/node_exporter/textfile_collector

Using a systemd timer instead of cron (more precise and observable):

# Create the service unit
sudo cat > /etc/systemd/system/spdk-exporter.service <<'EOF'
[Unit]
Description=SPDK Prometheus Metrics Exporter

[Service]
Type=oneshot
ExecStart=/usr/local/bin/spdk_exporter.sh
User=root
EOF

# Create the timer unit (collect every 15 seconds)
sudo cat > /etc/systemd/system/spdk-exporter.timer <<'EOF'
[Unit]
Description=Run SPDK exporter every 15 seconds

[Timer]
OnBootSec=30
OnUnitActiveSec=15

[Install]
WantedBy=timers.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now spdk-exporter.timer

# Verify
sudo systemctl list-timers | grep spdk
cat /var/lib/node_exporter/textfile_collector/spdk.prom

5.4 spdk_top and Watching Reactors

spdk_top is SPDK’s built-in real-time TUI; it connects to the running process and shows Threads, Pollers and core load:

cd /opt/spdk

# -r specifies the JSON-RPC socket; the default is /var/tmp/spdk.sock
sudo build/bin/spdk_top -r /var/tmp/spdk.sock

Press Tab in the interface to switch:

View Contents
Threads busy/idle percentage and Poller count for each SPDK Thread
Pollers Type (active/timed/paused), execution count and period for each Poller
Cores Load distribution per Reactor core

To script it, use JSON-RPC directly: framework_get_reactors for each Reactor’s busy/idle, bdev_get_iostat for each bdev’s IOPS and latency. DPDK telemetry is off by default, so don’t expect a usable endpoint under /var/run/dpdk/*/telemetry.

5.5 Suggested Key Alerting Metrics

Metric Alert condition Notes
spdk_up == 0 SPDK process unreachable
Reactor busy ratio > 95% for 5 minutes Reactor overloaded; add cores or rebalance connections
bdev read/write latency P99 above baseline (local NVMe can start from 100µs; relax for NVMe-oF per the network baseline) Abnormal latency; check NVMe health or QoS configuration
hugepage free < 10% of total Hugepages about to run out; expand or look for leaks
NVMe-oF connection count Sudden change > 20% Clients connecting/disconnecting en masse; check the network or client state

6. Upgrades and Rollback

6.1 Upgrade Strategy

SPDK is a userspace process, so upgrading means building the new version, stopping the old process and starting the new one. Two things matter: JSON-RPC interface compatibility and how long the outage and recovery take.

graph TD
    A["Read the release notes
confirm API changes"] --> B["Build the new version in test"] B --> C["Run regression tests
malloc + NVMe-oF validation"] C --> D{"Tests pass?"} D -->|"Yes"| E["Production: build the new version
keep the old binaries"] D -->|"No"| F["Fix scripts/config
for the new API"] F --> C E --> N["Point the service at the new directory"] N --> G["Maintenance window: stop the old process"] G --> H["Start the new process"] H --> I["Run the init script
JSON-RPC config"] I --> J["End-to-end verification"] J --> K{"Verification passes?"} K -->|"Yes"| L["Upgrade complete"] K -->|"No"| M["Roll back: stop the new process
start the old binaries"]

Build in parallel, prepare without downtime:

cd /opt/spdk
git fetch --tags

# List available versions
git tag -l 'v25.*' | sort -V

# Take v25.09 as an example; replace it with the tag you're upgrading to
# Build the new version in a separate directory (the running old version is unaffected)
sudo cp -a /opt/spdk /opt/spdk-v25.09
cd /opt/spdk-v25.09
git checkout v25.09
git submodule update --init --recursive
./configure --with-vhost --with-virtio --with-nvme-cuse
make -j$(nproc)

# Verify the new version built successfully
build/bin/spdk_tgt --version

# Point systemd at the new directory, but don't restart yet; switch in the maintenance window
sudo sed -i 's|/opt/spdk/|/opt/spdk-v25.09/|g' /etc/systemd/system/spdk-tgt.service
sudo systemctl daemon-reload

6.2 Checking API Compatibility

SPDK’s JSON-RPC interface can change between major versions (renamed parameters, deprecated methods). Before upgrading, always compare:

# Export the RPC method list of the current version
cd /opt/spdk
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock rpc_get_methods | jq -r '.[]' | sort > /tmp/rpc_methods_old.txt

# After building the new version, start a temporary instance and export its method list
cd /opt/spdk-v25.09
sudo build/bin/spdk_tgt -m 0x4 -s 512 -r /var/tmp/spdk_test.sock &
sleep 2
sudo python3 scripts/rpc.py -s /var/tmp/spdk_test.sock rpc_get_methods | jq -r '.[]' | sort > /tmp/rpc_methods_new.txt
sudo pkill -f "spdk_tgt.*spdk_test.sock"

# Compare the differences
diff /tmp/rpc_methods_old.txt /tmp/rpc_methods_new.txt

6.3 Rollback Plan

# Rollback only requires switching the binary path back
sudo systemctl stop spdk-tgt

# Point ExecStart, rpc.py and init-bdevs.sh back at the old version
sudo sed -i 's|/opt/spdk-v25.09|/opt/spdk|g' /etc/systemd/system/spdk-tgt.service
sudo systemctl daemon-reload
sudo systemctl start spdk-tgt

# Verify
sudo python3 /opt/spdk/scripts/rpc.py -s /var/tmp/spdk.sock framework_get_subsystems | jq '.[0]'

7. Production Best Practices

The following are production recommendations; I haven’t tested every one in this environment. Validate them in a test environment before going live.

7.1 NUMA Affinity

On multi-socket servers, the NUMA topology between NVMe devices, NICs and CPU/memory directly affects latency. The core principle: keep the CPU cores bound to SPDK Reactors, the hugepage memory and the NVMe device on the same NUMA node.

# 1) Confirm the NVMe device's NUMA node
cat /sys/bus/pci/devices/0000:5e:00.0/numa_node
# Example output: 1

# 2) Confirm the CPU cores for that NUMA node
lscpu | grep -i numa
# NUMA node0 CPU(s): 0-15,32-47
# NUMA node1 CPU(s): 16-31,48-63

# 3) Pick node 1's cores for SPDK (e.g. cores 16-19)
# Core mask: cores 16,17,18,19 -> 0xF0000
sudo build/bin/spdk_tgt -m 0xF0000 -s 4096 -r /var/tmp/spdk.sock

# 4) Make sure hugepages are allocated on node 1
echo 2048 | sudo tee /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages

Release already-allocated pages by writing 0 to nr_hugepages on node0 first, then allocate on node1; the hardcoded numbers on both sides must not exceed physical memory.

7.2 CPU Core Planning

Role Recommended cores Notes
Main Reactor 1 Handles JSON-RPC, the management plane and the Acceptor
I/O Reactor (NVMe-oF) N Each Reactor handles a set of connections; N depends on concurrent connections and target throughput
NVMe I/O channels Same as the Reactor count Each Reactor automatically creates a matching NVMe I/O Queue Pair
System reserve 2-4 Left for the OS kernel, monitoring collection, SSH, etc.

How many 4K IOPS a single Reactor can do depends on bdev type, protocol and I/O size. malloc bdev can reach hundreds of thousands; NVMe-oF/TCP usually hits the NIC or the TCP stack first. Don’t copy fixed numbers; run fio in the target environment and then decide the core count. For connections, start by watching 32-64 per Reactor; under RDMA a single Reactor carries more throughput, so you can use fewer cores.

7.3 NVMe-oF Transport Tuning Parameters

# Key TCP transport parameters
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock nvmf_create_transport \
    -t TCP \
    -u 8192 \
    -m 8 \
    -c 4096 \
    -n 4096 \
    -q 128

# Parameters:
# -u (io_unit_size)     : size of a single I/O transfer unit, 8192-131072 recommended
# -m (max_io_qpairs_per_ctrlr) : maximum I/O queue pairs per controller
# -c (in_capsule_data_size)    : data inlined in the capsule; increase it to cut RTT for small I/O
# -n (num_shared_buffers)      : number of shared buffers; increase for high concurrency
# -q (max-queue-depth) : maximum outstanding I/O per queue

7.4 Kernel Parameter Tuning

cat <<'EOF' | sudo tee /etc/sysctl.d/61-spdk-network.conf
# TCP buffer sizes for NVMe-oF/TCP
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 87380 16777216

# Increase connection backlog
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 8192

# Disable TCP slow start after idle (important for NVMe-oF)
net.ipv4.tcp_slow_start_after_idle = 0
EOF

sudo sysctl -p /etc/sysctl.d/61-spdk-network.conf

7.5 Security Hardening

# 1) Restrict JSON-RPC socket permissions (root and the spdk group only)
sudo groupadd -r spdk 2>/dev/null || true
sudo chgrp spdk /var/tmp/spdk.sock
sudo chmod 0660 /var/tmp/spdk.sock

# 2) To run as a non-root user, configure User= and the required capabilities in the service:
# CapabilityBoundingSet=CAP_SYS_ADMIN CAP_IPC_LOCK CAP_NET_ADMIN CAP_SYS_RAWIO
# AmbientCapabilities=CAP_SYS_ADMIN CAP_IPC_LOCK CAP_NET_ADMIN CAP_SYS_RAWIO
# The capabilities actually needed vary with version and driver; confirm in a test environment first.

# 3) Enable NVMe-oF/TLS (PSK)
# A PSK is a pre-shared key and needs no certificates:
# python3 scripts/rpc.py nvmf_subsystem_add_host <subnqn> <hostnqn> --psk /etc/spdk/psk.txt
# python3 scripts/rpc.py nvmf_subsystem_add_listener <subnqn> -t tcp -a <ip> -s 4420 --secure-channel

7.6 Graceful Shutdown and Resource Cleanup

The order of stopping affects data safety. The script below disconnects clients first, then deletes subsystems, and finally stops the process:

#!/usr/bin/env bash
# /opt/spdk/conf/graceful-shutdown.sh
# Written for this post's malloc + NBD + NVMe-oF topology. Real environments have more bdev types; replace the delete steps per type.

set -euo pipefail
RPC="/opt/spdk/scripts/rpc.py -s /var/tmp/spdk.sock"

echo "Step 1: Remove all NVMe-oF listeners..."
$RPC nvmf_get_subsystems | jq -r '
    .[] | select(.nqn != "nqn.2014-08.org.nvmexpress.discovery") |
    .nqn as $nqn | .listeners[]? |
    "\($nqn) \(.trtype) \(.traddr) \(.trsvcid)"
' | while read -r sub trtype traddr trsvcid; do
    echo "  $sub $trtype $traddr $trsvcid"
    $RPC nvmf_subsystem_remove_listener "$sub" -t "$trtype" -a "$traddr" -s "$trsvcid" || true
done

echo "Step 2: Wait for initiators to disconnect or I/O to drain..."
sleep 15

echo "Step 3: Delete the subsystem..."
$RPC nvmf_get_subsystems | jq -r '.[].nqn | select(. != "nqn.2014-08.org.nvmexpress.discovery")' |
while read -r sub; do
    $RPC nvmf_delete_subsystem "$sub"
done

echo "Step 4: Stop the NBD mapping..."
$RPC nbd_get_disks | jq -r '.[].nbd_device' 2>/dev/null |
while read -r nbd; do
    $RPC nbd_stop_disk "$nbd"
done

echo "Step 5: Delete the bdev (replace the command for the actual type)..."
$RPC bdev_malloc_delete Malloc0 2>/dev/null || true
# Real NVMe: $RPC bdev_nvme_detach_controller Nvme0
# RAID: $RPC bdev_raid_delete Raid0

echo "Step 6: Terminate the process..."
$RPC spdk_kill_instance SIGTERM

8. Troubleshooting Guide

8.1 Common Issues Quick Reference

Symptom Likely cause Check command Fix
configure reports --with-nvme-cuse requires libfuse3 Missing libfuse3-dev dpkg -s libfuse3-dev sudo apt install libfuse3-dev
configure reports autoreconf: not found Missing autotools command -v autoreconf sudo apt install autoconf automake libtool
make reports meson: not found Missing DPDK build tools command -v meson ninja sudo apt install meson ninja-build
make reports CUnit/Basic.h: No such file Missing CUnit headers dpkg -s libcunit1-dev sudo apt install libcunit1-dev
EAL: Not enough memory available Hugepages not actually allocated grep HugePages_ /proc/meminfo Drop caches and reset, or add memory
NVMe-oF connection rejected: does not allow host ... at this address Listener set to 0.0.0.0, or the host isn’t in the allowlist target log, nvmf_get_subsystems Use a specific IP for the listener, or nvmf_subsystem_add_host
spdk_tgt exits immediately on start Not enough hugepages grep HugePages_ /proc/meminfo Increase vm.nr_hugepages
spdk_tgt reports EAL: No free hugepages Hugepages held by another process sudo fuser /dev/hugepages/* Free them or add hugepages
spdk_tgt reports Cannot bind to core X Core doesn’t exist or is isolated lscpu, cat /sys/devices/system/cpu/online Adjust the -m core mask
rpc.py fails to connect Wrong socket path or the process isn’t running ls -la /var/tmp/spdk*.sock Check the -r argument and the process state
VFIO binding fails IOMMU not enabled dmesg | grep -i iommu Enable IOMMU in GRUB (see 3.5)
NVMe-oF connection times out Firewall, IP unreachable, or the listener isn’t added ss -tlnp | grep 4420 Check the listener config and the network
fio reports No such device The NBD device isn’t ready lsblk | grep nbd Confirm nbd_start_disk completed
Abnormally high latency Cross-NUMA access or CPU overload numastat, Reactor busy ratio Fix NUMA affinity (see 7.1)
Memory keeps growing Hugepage leak (bdevs not deleted properly) compare grep HugePages_ /proc/meminfo Make sure all bdevs/subsystems are cleaned up

8.2 Log Diagnostics

# Adjust the log level at runtime (no restart)
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock log_set_flag bdev
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock log_set_level DEBUG

# Show the current log flags
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock log_get_flags | jq

# Restore defaults
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock log_set_level NOTICE
sudo python3 scripts/rpc.py -s /var/tmp/spdk.sock log_clear_flag bdev

8.3 Core Dump Analysis

# Make sure core dumps are enabled
ulimit -c unlimited
echo '/tmp/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern

# If spdk_tgt crashes, analyze with gdb
gdb /opt/spdk/build/bin/spdk_tgt /tmp/core.spdk_tgt.<pid>
# (gdb) bt        <- show the call stack
# (gdb) thread apply all bt  <- stacks for all threads

9. Further Reading

Resource URL Notes
SPDK documentation https://spdk.io/doc/ API reference, architecture, example code
SPDK GitHub https://github.com/spdk/spdk Source, issues, release notes
SPDK JSON-RPC reference https://spdk.io/doc/jsonrpc.html Detailed parameters for every RPC method
NVMe specifications https://nvmexpress.org/specifications/ NVMe Base / NVMe-oF protocol specs
DPDK documentation https://doc.dpdk.org/ EAL, hugepages, VFIO internals
fio documentation https://fio.readthedocs.io/ Complete reference for the I/O benchmark tool
SPDK NVMe-oF https://spdk.io/doc/nvmf.html Target/initiator configuration and protocol details
SPDK vhost https://spdk.io/doc/vhost.html QEMU/KVM virtio backend
SPDK blobstore https://spdk.io/doc/blob.html blobstore/blobfs design and API
Ceph NVMe-oF Gateway https://github.com/ceph/ceph-nvmeof RBD NVMe-oF gateway built on SPDK
DAOS https://github.com/daos-stack/daos HPC/AI storage that uses SPDK to manage NVMe
SPDK CSI https://github.com/spdk/spdk-csi Kubernetes CSI driver
nvme-cli man nvme Kernel NVMe management tool manual

Appendix: Minimal Reproduction Script

The script below does a from-scratch SPDK build, start, malloc bdev creation and fio validation on any Debian 12 host, with no NVMe hardware and no kernel boot parameter changes:

To try it in a Homelab, one Debian 12 VM is enough: 4 vCPU, 8 GB RAM, 32 GB disk. nbd and nvme-tcp use Debian’s bundled modules; if modprobe nbd can’t find the module, install linux-modules-extra-$(uname -r) first. VFIO/NVMe passthrough needs extra NVMe and IOMMU; fio numbers on a virtual disk only validate functionality and don’t represent NVMe performance.

#!/usr/bin/env bash
# spdk-quickstart.sh - minimal reproducible SPDK validation on Debian 12
# Usage: sudo bash spdk-quickstart.sh

set -euo pipefail

echo "=== [1/7] Install dependencies ==="
apt update
apt install -y git build-essential meson ninja-build pkg-config \
    python3 python3-venv python3-pip \
    python3-pyelftools libnuma-dev libssl-dev libaio-dev libfuse3-dev \
    uuid-dev libncurses-dev libcunit1-dev autoconf automake libtool \
    jq curl fio nasm

echo "=== [2/7] Clone and build SPDK v24.09 ==="
cd /opt
[ -d spdk ] || git clone https://github.com/spdk/spdk.git
cd spdk
git checkout v24.09
git submodule update --init --recursive
./configure
make -j$(nproc)

echo "=== [3/7] Configure hugepages ==="
sysctl -w vm.nr_hugepages=1024
if [ "$(awk '/HugePages_Total/{print $2}' /proc/meminfo)" -lt 1024 ]; then
    # With memory fragmentation or a lot of page cache, the kernel may only allocate part of it
    sync
    echo 3 > /proc/sys/vm/drop_caches
    sysctl -w vm.nr_hugepages=1024
fi
mkdir -p /dev/hugepages
mount -t hugetlbfs nodev /dev/hugepages 2>/dev/null || true
grep HugePages_ /proc/meminfo
if [ "$(awk '/HugePages_Total/{print $2}' /proc/meminfo)" -lt 1024 ]; then
    echo "Not enough hugepages allocated; 1024 pages (2GB) are required" >&2
    exit 1
fi

echo "=== [4/7] Start spdk_tgt ==="
# -u skips PCI; pure malloc validation doesn't need VFIO
build/bin/spdk_tgt -m 0x1 -s 1024 -u -r /var/tmp/spdk.sock &
SPDK_PID=$!
sleep 2
echo "spdk_tgt PID: $SPDK_PID"

echo "=== [5/7] Create malloc bdev and NBD mapping ==="
python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_create -b Malloc0 512 4096
modprobe nbd nbds_max=16
python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_start_disk Malloc0 /dev/nbd0
sleep 1
lsblk | grep nbd0

echo "=== [6/7] Run fio benchmark ==="
fio --name=spdk-verify \
    --filename=/dev/nbd0 \
    --ioengine=libaio \
    --direct=1 \
    --rw=randrw \
    --rwmixread=70 \
    --bs=4k \
    --iodepth=32 \
    --numjobs=1 \
    --time_based \
    --runtime=10 \
    --group_reporting

echo "=== [7/7] Cleanup ==="
python3 scripts/rpc.py -s /var/tmp/spdk.sock nbd_stop_disk /dev/nbd0
python3 scripts/rpc.py -s /var/tmp/spdk.sock bdev_malloc_delete Malloc0
kill $SPDK_PID 2>/dev/null; wait $SPDK_PID 2>/dev/null || true

echo "=== SPDK quickstart verification PASSED ==="

Summary

The content here falls into three parts. The principles section explains why SPDK is fast, where the speed comes from, and how the Reactor model affects tuning; the deployment section gives reproducible build, hugepage, VFIO and systemd steps on Debian 12; the verification section goes from malloc/NBD all the way to cross-host NVMe-oF, with measured numbers on a 1Gb link in 4.5.

If your application already runs on a kernel filesystem and you just want I/O to be a bit faster, look at io_uring first. If you’re building an NVMe-oF target, a vhost-user backend, or want to control the data plane yourself, then consider SPDK. Its performance is paid for with dedicated CPUs, hugepages, VFIO and higher operational complexity; work out those costs before deciding.