Introduction
Managing high-dimensional vector embeddings at scale often leads to a critical bottleneck: the memory wall. As datasets grow into the billions of vectors, traditional in-memory indexing methods like HNSW quickly become prohibitively expensive and hardware-limited. DiskANN, developed by Microsoft, solves this by shifting the primary index storage from RAM to SSD, enabling billion-scale approximate nearest neighbor (ANN) search with millisecond latency and a fraction of the memory footprint. With nearly 2,000 GitHub stars, it has become a foundational technology for modern vector databases and enterprise search systems.
What Is DiskANN?
DiskANN is a high-performance vector indexing library that enable fast and accurate approximate nearest neighbor (ANN) search on massive datasets using a single node with limited memory and an SSD. Unlike traditional ANN algorithms that require the entire index to reside in DRAM, DiskANN strategically leverages SSD storage to store the full vector index and raw embeddings, while keeping only a compressed version of the data in RAM.
Maintained by Microsoft, the project is licensed under the MIT License, and is written primarily in C++ and Rust. It implements the Vamana graph algorithm, which is specifically optimized for disk-based access patterns to minimize I/O overhead and maintain high recall.
Why DiskANN Matters
The primary gap DiskANN fills is the scalability gap between research-grade ANN algorithms and industry-scale production needs. Before DiskANN, developers had to choose between high-accuracy in-memory indices (which were limited to roughly 100-200 million vectors per machine) or slower, less accurate disk-based methods. DiskANN provides a “third way,” allowing a single machine to index up to a billion vectors while maintaining 95% search accuracy and 5ms latencies.
This shift is critical for the rise of Retrieval-Augmented Generation (RAG) and AI agents. As enterprise knowledge bases grow to encompass billions of document chunks, the cost of maintaining them in RAM becomes unsustainable. DiskANN allows these systems to run on commodity hardware with NVMe SSDs, reducing infrastructure costs by up to 80% compared to RAM-only solutions.
The project’s traction is evident in its adoption by major systems. Its core ideas have been integrated into Microsoft Bing, Azure databases, and the PostgreSQL ecosystem via extensions like pgvectorscale and pg_diskann, making it a standard for high-scale vector search.
Key Features
- Vamana Graph Index: A specialized graph structure that allows for efficient navigation across the vector space with fewer hops, specifically designed to minimize SSD read operations.
- Product Quantization (PQ): An in-memory compression technique that reduces the size of vectors, enabling rapid approximate distance calculations in RAM before fetching full-precision vectors from disk.
- Billion-Scale Indexing: The ability to index and search over a billion vectors on a single workstation with an SSD, bypassing the DRAM limitations of traditional ANN search.
- High Recall and Low Latency: Achieves high search accuracy (often >95%) with millisecond-level query response times, even when the dataset exceeds available RAM.
- Filtered Search Support: Capability to perform vector search combined with auxiliary metadata filters (e.g., date range, region), providing high recall and significantly better performance than simple post-filtering.
- Real-Time Updates (FreshDiskANN): An extension of the core algorithm that allows for real-time inserts, deletes, and updates to the index without requiring a full rebuild.
- Distributed Indexing: Support for creating a single logical, distributed index across thousands of machines for even larger datasets (e.g., 50 billion points).
- Hardware Optimization: Specifically tuned for NVMe SSDs to maximize I/O throughput and minimize latency during the search process.
How DiskANN Compares
| Feature | DiskANN | HNSW | IVF-Flat |
|---|---|---|---|
| Primary Storage | SSD + RAM | RAM Only | Disk/RAM |
| Max Dataset Size (Single Node) | 1B+ Vectors | ~200M Vectors | High |
| Memory Footprint | Low (Compressed) | Very High | Moderate |
| Query Latency (p95) | ~5-10ms | ~2ms | Moderate |
| Search Accuracy (Recall) | High (>95%) | Very High | Moderate |
DiskANN represents a fundamental shift in the trade-off between cost and performance. While HNSW is the gold standard for sub-millisecond latency and maximum recall, it is limited by the physical size of RAM. For datasets that exceed 200 million vectors, HNSW becomes prohibitively expensive. DiskANN accepts a slight increase in latency (from 2ms to 8ms) to achieve a massive increase in capacity, allowing a single machine to handle datasets that would otherwise require a large cluster of RAM-heavy machines.
Compared to IVF-Flat (Inverted File Index), DiskANN generally provides higher recall and more consistent performance. IVF often requires re-clustering when the dataset grows, whereas DiskANN’s Vamana graph is more versatile and handles larger scales more gracefully. For most enterprise-scale AI applications, DiskANN is the optimal choice when the dataset is too large for RAM but requires high accuracy.
Getting Started: Installation
DiskANN can be built from source or run via Docker for a more isolated environment. Prerequisites include a C++ compiler, CMake, and the Boost library.
Build from Source
git clone https://github.com/microsoft/DiskANN.git
cd DiskANN
mkdir build && cd build
cmake ..
make
Using Docker
Using Docker is the recommended method for quick testing to avoid dependency issues with Boost and C++ versions.
docker build -t diskann .
docker run -it --name diskann --memory="4g" diskann
Once inside the container, you can proceed to build the index and perform searches using the provided CLI tools.
How to Use DiskANN
The basic workflow for using DiskANN involves three main stages: data preparation, index construction, and search execution. First, you must convert your vector data into a binary format (.fbin) that DiskANN can read efficiently.
Using the provided utility, you can convert a standard fvecs file to binary:
./tests/utils/fvecs_to_bin float data/sift/sift_learn.fvecs data/sift/sift_learn.fbin
Once the data is in binary format, you can build the Vamana graph index. This process involves calculating distances and pruning edges to create a optimized search path. You then run the search tool to query the index for the nearest neighbors of a query vector.
Code Examples
DiskANN provides a C++ API for integration into larger systems. The following example demonstrates how to load an index and perform a search query.
#include "diskann.h"
int main() {
// Initialize the index
DiskANN::Index index;
// Load the index from SSD storage
index.load("data/index_file.bin");
// Define a query vector
std::vector<float> query_vector = {0.1f, 0.2f, 0.3f, ...};
// Perform the approximate nearest neighbor search
auto result = index.search(query_vector);
return 0;
}
This code snippet shows the core logic: the index is mapped to disk, and the search algorithm navigates the Vamana graph, using the in-memory PQ embeddings to scout promising paths before fetching full vectors from the SSD for final verification.
Real-World Use Cases
- Enterprise RAG Systems: Companies building Retrieval-Augmented Generation systems over billions of document chunks can use DiskANN to ensure high-recall retrieval without needing massive, expensive RAM clusters.
- AI Agent Contextual Memory: Agentic systems that accumulate interaction history and preferences as vectors over time can use DiskANN to search an unbounded, growing memory corpus without RAM becoming a bottleneck.
- Large-Scale Semantic Search: E-commerce platforms and media libraries with billions of product or content embeddings can provide near-instant semantic search results using commodity NVMe SSDs.
- High-Mutation Vector Databases: By using FreshDiskANN, systems that require real-time updates to their vector indices (such as transactional data) can maintain high search performance without full index rebuilds.
Contributing to DiskANN
DiskANN is an open-source project maintained by Microsoft. Contributions are welcome through the standard GitHub flow: fork the repository, create a feature branch, and submit a pull request. Developers are encouraged to check for “good first issues” to get started.
The project follows a Contributor License Agreement (CLA) to ensure legal clarity for all contributions. Before submitting your first PR, you possibilely need to sign the Microsoft CLA.
Community and Support
The primary hub for the DiskANN community is the GitHub repository, where developers can use GitHub Discussions and Issues to report bugs or ask for architectural guidance. The project also maintains a detailed Wiki on GitHub for best practices regarding serialization and deserialization frameworks in Rust.
Because DiskANN is part of a larger research effort by Microsoft Research (MSR), much of the technical depth is found in the original research papers and the official Microsoft Research blog, which provides the theoretical foundation for the Vamana graph and FreshDiskANN.
Conclusion
DiskANN is the right choice for developers and architects who need to scale vector search to billions of points without breaking their infrastructure budget. It is the optimal solution when the dataset size exceeds the practical limits of DRAM and when high recall is a non-negotiable requirement for the quality of AI applications.
While it is slightly slower than pure RAM-based indices like HNSW, the trade-off is a massive increase in capacity and a cost reduction of up to 80%. For those building the next generation of enterprise AI, DiskANN provides the necessary foundation for billion-scale retrieval.
Star the repo, try the quickstart, and join the community to start building high-performance vector search into your database.
What is DiskANN and what problem does it solve?
DiskANN is a vector indexing library that solves the memory bottleneck of approximate nearest neighbor (ANN) search. It allows billions of vectors to be indexed on a single machine using SSD storage instead of requiring the entire index to reside in expensive RAM.
How does DiskANN compare to HNSW?
HNSW is an in-memory index that offers faster query latency but is limited by RAM capacity. DiskANN uses a disk-based Vamana graph, allowing it to index 5-10x more vectors per machine than HNSW while maintaining high recall and millisecond latency.
Can I use DiskANN for real-time data updates?
Yes, through the FreshDiskANN extension. FreshDiskANN allows for real-time inserts, deletes, and updates to the vector index without requiring a full rebuild, making it suitable for transactional vector data.
How do I install DiskANN?
DiskANN can be installed by cloning the GitHub repository and building it with CMake and a C++ compiler, or by running it via the provided Dockerfile for a more isolated environment.
What is the Vamana graph in DiskANN?
Vamana is a specialized graph-based index that is optimized for disk access patterns. It reduces the number of hops required to navigate the vector space, which minimizes costly SSD reads during search.
Can I use DiskANN for filtered vector search?
Yes, DiskANN supports filtered search, which allows you to combine vector similarity search with metadata filters (e.g., date, region) to retrieve the most similar vectors that satisfy specific criteria.
What license does DiskANN use?
DiskANN is licensed under the MIT License, allowing for free use, modification, and distribution in both open-source and commercial projects.
