Serving Billion-Scale Vector Search (DiskANN) on Local NVMe Arrays

Serving Billion-Scale Vector
Verified Answer

Serving billion-scale vector search with DiskANN on local NVMe arrays keeps compressed Product Quantization vectors in RAM while streaming Vamana graph neighborhoods directly from flash. Instead of provisioning terabytes of DRAM for full in-memory HNSW indexes, engines like Qdrant and Milvus issue parallel async NVMe reads per query hop. High-IOPS Gen4/Gen5 SSDs deliver sub-10ms recall at a fraction of memory cost.

Billion-Scale Vector Search with DiskANN and On-Disk HNSW on NVMe

Keeping one billion 768-dimensional float32 embeddings and HNSW graph edges in DRAM requires 3.5+ TB of RAM per replica. Deploying diskann vector search nvme architectures (and Qdrant/Milvus on-disk indexes) compresses Product Quantization (PQ) codes into 32–64 GB of RAM while streaming full-precision Vamana graph neighborhoods directly from PCIe NVMe SSDs via asynchronous io_uring beam search.

Core Disk-Backed Vector Stack: Vamana graph layout, Product Quantization (PQ) in RAM, 4KB-aligned node blocks, io_uring async beam search (beamwidth), Qdrant on_disk, and Milvus Knowhere DiskANN

Holding billion-scale 768-dimensional HNSW vector graphs entirely in DRAM forces massive memory footprints per replica. Disk-backed Vamana indexes keep compact quantized codes in RAM while streaming graph hops from NVMe, provided random 4KB queues stay tuned. Explore Qdrant and Milvus DiskANN parameters and io_uring setup.

Prohibitive In-Memory HNSW RAM

Storing a billion dense embeddings plus graph edges in DDR5 memory requires multiple terabytes of RAM per search node.

Beamwidth vs. Random 4K IOPS

Graph traversal latency depends on parallel async NVMe reads and 4KB-aligned node layouts to preserve Recall@10 under load.

Tune Beam Search & io_uring

Configure PQ compression in RAM, set io_uring async scorers with optimal beamwidth, and verify p99 search latency.

How Vamana Graphs, PQ Compression, and Beam Search Minimize NVMe Hops

Standard HNSW graphs are notoriously hostile to SSDs because traversing from the sparse upper layers down to the dense base layer triggers dozens of sequential, dependent 64-byte pointer chases. Each hop waits on the previous hop—turning a single query into 30–50 serialized QD1 disk reads totaling 3–5 milliseconds.

Vamana Flat Graph Co-Location and PQ In-Memory Pruning

Microsoft’s DiskANN solves SSD hop latency with the Vamana graph algorithm and two hardware-aware optimizations:

  • Co-Located 4KB Disk Sectors: Each node’s full-precision vector (e.g., 768 × 4 bytes = 3,072 bytes) and its adjacency list of R neighbor IDs (e.g., 64–128 neighbors × 4 bytes = 256–512 bytes) are packed together into a single contiguous 4KB-aligned block on NVMe. Reading one 4KB sector fetches both the exact vector and its outgoing edges in a single DMA transfer.
  • In-Memory Product Quantization (PQ): DiskANN compresses every vector into a 32-byte or 64-byte PQ code stored permanently in RAM (32–64 GB for 1 billion vectors). During traversal, approximate distances to all neighbors are computed instantaneously in CPU cache using PQ lookup tables, and only the top-W candidates (the beam width) trigger actual NVMe reads for exact distance re-ranking.
  • Entry-Point Node Caching: The top 1–5% most-frequently visited hub nodes near the graph’s medoid are pinned in RAM (num_nodes_to_cache), eliminating NVMe reads during the initial hops of every query.

Comparing In-Memory HNSW, Qdrant Memmap/PQ, and Milvus DiskANN

Choosing between quantized HNSW with mmap and true Vamana/DiskANN depends on your RAM budget, recall target, and NVMe random 4K IOPS capacity:

Vector Index Architecture RAM Footprint (100M × 768d) NVMe I/O Pattern per Query Typical Latency & Recall@10
In-Memory HNSW (float32) ~360–420 GB RAM Zero disk reads on hot path 1–3 ms; 98%+ Recall@10
Qdrant on_disk + Binary/Scalar Quantization ~12–75 GB RAM (quantized in RAM) io_uring async rescore of top-K 4–12 ms; 95–98% Recall@10
Milvus Knowhere DISKANN ~8–32 GB RAM (PQ + top cache) O_DIRECT batched 4KB beam reads 5–18 ms; 95–97% Recall@10
Unquantized HNSW over mmap Depends on OS page cache Synchronous page-fault thrashing 50–300+ ms under cache pressure

Configuring Qdrant On-Disk Storage and Milvus DiskANN Beam Parameters

Both Qdrant and Milvus expose explicit configuration knobs to keep quantized vectors or PQ tables pinned in RAM while streaming exact vectors from local NVMe. In Qdrant, enabling async_scorer: true switches disk reads from blocking mmap page faults to batched io_uring submissions.

Terminal / Bash

# Qdrant collection configuration: on-disk vectors + in-RAM Scalar Quantization + io_uring
curl -X PUT "http://localhost:6333/collections/billion_embeddings" \
  -H "Content-Type: application/json" -d '{
  "vectors": {
    "size": 768,
    "distance": "Cosine",
    "on_disk": true
  },
  "hnsw_config": {
    "m": 16,
    "ef_construct": 128,
    "on_disk": false
  },
  "quantization_config": {
    "scalar": {
      "type": "int8",
      "quantile": 0.99,
      "always_ram": true
    }
  }
}'

In Milvus (Knowhere engine), DISKANN relies on pq_code_budget_gb_ratio (fraction of raw vector size allocated for in-memory PQ codes, typically 0.125) and search_cache_budget_gb_ratio (fraction of index cached in RAM for entry hubs). During search, beamwidth controls how many parallel NVMe 4KB reads are dispatched per graph hop.

Terminal / Bash

# PyMilvus: Creating and querying a DiskANN index on local NVMe
index_params = client.prepare_index_params()
index_params.add_index(
    field_name="embedding",
    index_type="DISKANN",
    metric_type="COSINE",
    params={
        "search_list": 100,
        "pq_code_budget_gb_ratio": 0.125,
        "search_cache_budget_gb_ratio": 0.10
    }
)

# Query with beamwidth=8 (8 parallel NVMe reads per Vamana hop)
results = client.search(
    collection_name="billion_embeddings",
    data=[query_vector],
    limit=10,
    search_params={"metric_type": "COSINE", "params": {"search_list": 80, "beamwidth": 8}}
)

Aligning NVMe Queue Depth, io_uring Async Scorer, and 4KB Block Layout

Because each DiskANN query issues beamwidth (4 to 16) concurrent 4KB random reads per hop across ~10–15 hops, a server handling 200 QPS drives 200 × 8 = 1,600 concurrent I/Os at any instant—saturating high queue depths across the NVMe array. Understanding how NVMe queue depth QD1 vs. QD256 affects read latency is essential for sizing vector search QPS ceilings.

If your NVMe array is also shared with AI training or PyTorch checkpointing workloads, heavy sequential write bursts will bloat read queue latency. Always isolate DiskANN index volumes onto dedicated enterprise read-intensive or mixed-use NVMe drives with consistent sub-100µs QD1–QD32 random read latency.

Linux Kernel Queue, Readahead, and Index Build Write-Amplification Tuning

When serving DiskANN or Qdrant on_disk collections, Linux’s default block-layer readahead (128 KB) wastes up to 31× more PCIe bandwidth than needed because graph hops target scattered 4KB sectors across terabytes of index files. Apply these host-level NVMe tunings on dedicated vector search nodes:

  • Set read_ahead_kb=0 (or 16) for Random Beam Search: Disabling aggressive sequential prefetch prevents the kernel from pulling 128KB of irrelevant neighboring vectors into page cache on every 4KB Vamana hop.
  • Schedule Asynchronous fstrim During Off-Peak Hours: Building and merging billion-scale Vamana graphs writes and deletes hundreds of gigabytes of temporary segment files; periodic fstrim keeps NAND garbage collection from colliding with daytime search QPS.
  • Raise File Descriptor and memlock Limits: High-shard Qdrant and Milvus nodes open thousands of segment files and lock PQ tables; configure LimitNOFILE=1048576 and LimitMEMLOCK=infinity in their systemd unit files.
Terminal / Bash

# Optimize NVMe queue for scattered 4KB DiskANN beam reads
echo none | sudo tee /sys/block/nvme0n1/queue/scheduler
echo 0 | sudo tee /sys/block/nvme0n1/queue/read_ahead_kb
echo 2 | sudo tee /sys/block/nvme0n1/queue/rq_affinity

# Verify random 4K read IOPS at QD64 matches DiskANN multi-query concurrency
sudo fio --name=diskann_sim --filename=/dev/nvme0n1 --ioengine=io_uring \
  --rw=randread --bs=4k --iodepth=64 --numjobs=4 --direct=1 \
  --runtime=20 --clat_percentiles=1 --group_reporting

Production Guardrails for Disk-Backed Vector Search Nodes

Apply these four guardrails when running DiskANN or on-disk HNSW in production:

Enable io_uring Async Scorer in Qdrant

Set storage.performance.async_scorer: true in Qdrant’s config so rescoring batches 4KB reads via io_uring instead of blocking worker threads on mmap page faults.

Tune Beamwidth Against NVMe IOPS Budget

Raising beamwidth from 4 to 16 reduces hop count and latency at low QPS, but multiplies NVMe IOPS per query by 4x—exhausting SSD IOPS sooner under high concurrency.

Set vm.max_map_count for Large Collections

Memory-mapped segments across hundreds of shards can hit Linux’s default 65,530 VMA limit; set vm.max_map_count = 1048576 in /etc/sysctl.conf.

Verify 4Kn Alignment and No Swap

Disable swap (swapoff -a) so PQ tables and HNSW entry hubs never page out, and align XFS/ext4 partitions to 4KB boundaries to prevent read-modify-write penalties.

Troubleshooting High p99 Search Latency, Recall Drops, and Config Rollback

If disk-backed vector queries suddenly spike past 50 ms p99, check three metrics immediately: NVMe queue depth / r_await via iostat, major page faults (majflt/s via pidstat -r), and container memlock / io_uring syscall restrictions in Docker or Kubernetes.

Terminal / Bash

# 1. Monitor major page faults (mmap thrashing) and NVMe read latency
pidstat -r -p $(pgrep qdrant) 1 5
iostat -xz /dev/nvme0n1 1 5

# 2. Verify io_uring is not blocked by seccomp/container runtime
grep Seccomp /proc/$(pgrep qdrant)/status

# 3. Safe Rollback: if PQ compression degrades Recall@10 below SLA, increase oversampling
# or keep HNSW graph edges (on_disk: false) in RAM while leaving raw vectors on NVMe

When recall drops below target after enabling aggressive Binary Quantization (BQ) or low-bit PQ, increase the rescoring multiplier (oversampling: 3.0 in Qdrant or higher search_list in Milvus) so more exact vectors are fetched from NVMe for final re-ranking. If NVMe IOPS saturates during peak traffic, reduce beamwidth to 4 and increase search_cache_budget_gb_ratio to absorb upper-graph hops in RAM. To roll back kernel readahead changes if sequential index builds slow down, restore echo 128 | sudo tee /sys/block/nvme0n1/queue/read_ahead_kb.

Sizing NVMe IOPS and Endurance for Billion-Scale Vector Updates

Unlike read-only static benchmarks, production RAG and recommendation pipelines continuously upsert new embeddings and merge DiskANN/HNSW segments in the background. When sizing NVMe hardware for 1 billion 768-dimensional vectors (~3.2 TB raw + graph metadata), provision at least 2× raw index capacity (6.4–7.68 TB NVMe) so background segment compaction and Vamana graph rebuilds never push SSD utilization past 75%. Choose mixed-use enterprise NVMe drives rated for 1–3 DWPD (Drive Writes Per Day) with Power Loss Protection so concurrent segment merges do not degrade daytime io_uring beam-search p99 latency. On multi-socket servers, pin each Qdrant or Milvus shard to the NUMA node directly attached to its local NVMe drives so 4KB beam-search DMA transfers never traverse cross-socket interconnects.

How does beamwidth affect NVMe queue depth and query latency?

Each hop of a DiskANN query dispatches beamwidth parallel 4KB reads to NVMe. Raising beamwidth from 4 to 8 reduces the number of sequential hops (lowering single-query latency), but doubles per-query IOPS consumption—so tune it against your peak QPS and SSD IOPS ceiling.

Can I use RAID0 across multiple NVMe drives for DiskANN collections?

Yes. Striping 2 to 4 local PCIe Gen4/Gen5 NVMe drives via mdadm --level=0 --chunk=128 aggregates random 4K read IOPS linearly for high-QPS DiskANN workloads, provided all drives sit on the same NUMA socket and cluster replication handles node-level redundancy.

Does DiskANN require 4Kn formatting on NVMe drives?

While DiskANN works on 512e drives, formatting enterprise NVMe namespaces to native 4Kn aligns Vamana’s 4KB node-plus-neighbor blocks 1:1 with physical NAND pages, eliminating controller read-modify-write overhead during concurrent beam searches.

Frequently Asked Questions

Why does DiskANN prefer io_uring or O_DIRECT over standard mmap?

Standard mmap blocks the calling worker thread on every page fault and triggers kernel readahead amplification. Using io_uring or batched O_DIRECT lets a single query thread dispatch all beamwidth (4–16) 4KB NVMe reads concurrently in one submission.

How much RAM do I still need for 1 billion vectors with DiskANN on NVMe?

Plan for 40 GB to 80 GB of RAM for 1 billion vectors: roughly 32–64 GB for compressed 32/64-byte PQ codes plus 10–16 GB for cached Vamana entry-point hubs and OS/runtime overhead—down from ~3.5+ TB for full in-memory HNSW.

Does DiskANN work well on cloud EBS/network block storage?

No. Networked block storage (like EBS) adds 300–1,000+ microseconds per random 4KB read, which multiplies across 10–15 graph hops into 15–40 ms per query. DiskANN is engineered specifically for local PCIe Gen4/Gen5 NVMe SSDs with sub-100µs read latency.

Should I put Qdrant’s HNSW graph on disk too, or only the raw vectors?

Keep HNSW graph links in RAM (hnsw_config.on_disk: false) alongside quantized vectors (always_ram: true) whenever possible, and place the large float32 original vectors on NVMe (vectors.on_disk: true). That hybrid layout preserves sub-10ms latency while cutting RAM usage by 4x–10x.

How many NVMe IOPS are required for 500 QPS on DiskANN?

If each query traverses 10 hops with beamwidth=4 (40 reads/query), 500 QPS requires ~20,000 random 4KB read IOPS—easily handled by a single enterprise Gen4 NVMe SSD, which delivers 1M+ random read IOPS.

Cut Vector Database RAM Spend by 80% on Local PCIe NVMe

Deploy Qdrant and Milvus DiskANN clusters on bare-metal servers with direct-attached PCIe Gen4/Gen5 NVMe arrays, high-frequency EPYC/Xeon CPUs, and predictable sub-100µs random read latency.

Build DiskANN NVMe Clusters