Storage-Optimized Disk Index (DiskANN)
When vector datasets exceed available memory, in-memory indexes such as HNSW and IVF_FLAT are constrained by memory capacity and struggle to meet both performance and cost requirements simultaneously. DiskANN offloads index data to disk, delivering high search accuracy and query performance even when the data volume exceeds available memory capacity. DiskANN is suitable for vector search scenarios at the scale of billions of vectors or more.
Limits
| Item | Description |
| Index enablement | Clusters whose Compute NodeCU Type is Storage-optimized have DiskANN enabled by default. Other instances can explicitly specify the index type as DISKANN when creating an index. |
| Deployment mode version requirement | Disk mode requires Alibaba Cloud Milvus cluster version 2.6.18 or later. Version 2.6.3 only supports performance mode. |
How it works
DiskANN combines two technologies — Vamana graph and RaBitQ quantization — to achieve efficient vector search on disk.
Vamana graph
The Vamana graph is the core structure of DiskANN's disk-based strategy. Unlike HNSW's multi-layer structure, Vamana uses a single-layer sparse graph and builds it through two rounds of pruning. This approach maintains graph connectivity while introducing more long-range edges, reducing the number of hops needed for search convergence.
The construction process is as follows:
Initial random connections: Each vector serves as a node in the graph. Nodes are initially connected randomly to form a dense network, typically with approximately 500 edges per node, to ensure connectivity.
Two-round pruning optimization: Redundant edges are removed and low-quality connections are pruned based on node distance, prioritizing high-quality edges. The maximum number of edges per node is controlled by
MaxDegree. Long-range edges are introduced, connecting distant data points in the vector space to create navigation shortcuts that speed up graph traversal. The breadth of neighbor search during graph construction is determined bySearchListSize.
In the open-source DiskANN implementation, each node's neighbor list and its full-precision vector are stored in the same disk sector. During search, a single disk read retrieves both the neighbor relationships and the original vector, enabling implicit reranking, but the entire search process involves extensive sequential disk I/O. Alibaba Cloud Milvus reorganizes the Vamana graph index in memory, eliminating disk I/O during the search process and only reading original vectors from disk during the final reranking phase.
RaBitQ quantization
RaBitQ (Random Bit Quantization) normalizes vectors and maps them to vertices of a hypercube, requiring only 1 bit per dimension. This compresses storage overhead and accelerates approximate distance computation between vectors.
In high-dimensional spaces, the angles between random vectors are highly concentrated. The quantization error when mapping to hypercube vertices converges at a rate of O(1/√d), meaning higher dimensions yield smaller quantization errors. In 768-dimensional space, the error from 1-bit quantization is already very small. Alibaba Cloud Milvus extends the standard 1-bit RaBitQ with a 4-bit extension mode, using 4 bits per dimension to encode residual information, balancing the compression ratio and accuracy.
Enable the DiskANN index
Step 1: Plan memory and instance types
Use the following formulas to calculate the theoretical minimum memory required. Actual memory usage is slightly higher than the theoretical value. Reserve resources at 1.5x the theoretical value.
Performance mode:
Memory = Number of vectors × (Dimension / 2 + 228) bytesDisk mode:
Memory = Number of vectors × (Dimension / 2) bytesTaking 100 million 768-dimensional vectors as an example:
| Deployment Mode | Theoretical Memory | Recommended Memory (x 1.5) | Recommended Instance Type |
| Performance mode | 100 million x (384 + 228) bytes ≈ 57 GB | Approximately 85 GB | 2 compute nodes with 16C64G |
| Disk mode | 100 million x 384 bytes ≈ 36 GB | Approximately 54 GB | 1 compute node with 16C64G |
Step 2: Create a storage-optimized cluster
When creating an Alibaba Cloud Milvus instance, set the Compute NodeCU Type to Storage-optimized. After the cluster is created, no additional configuration is required — the DiskANN RaBitQ index type is used by default. When you create a collection with the index type set to AUTOINDEX, the system automatically selects DiskANN as the underlying index implementation.
For detailed instructions on creating an instance, see Quick start: Create a Milvus instance.
When using AUTOINDEX, describe_index returns the index type as AUTOINDEX and does not display the automatically matched underlying index. To verify the actual index type in effect, query segment-level information. If index_name is DISKANN, it indicates that DiskANN has been matched:
from pymilvus import connections, utility
connections.connect(uri="http://<endpoint>:19530", token="<user>:<password>")
for seg in utility.get_query_segment_info("<collection_name>"):
print(seg.segmentID, seg.num_rows, seg.index_name)Step 3: Switch deployment mode (optional)
The same DiskANN RaBitQ index supports two deployment modes. Choose the loading and search approach based on your business requirements:
| Deployment Mode | Loading Behavior | Scenarios |
| Performance mode (default) | Both the Vamana graph and RaBitQ quantized encodings are loaded into memory | Online search scenarios requiring high QPS and low latency |
| Disk mode | The Vamana graph is stored on disk; only RaBitQ encodings are loaded into memory | Cost-sensitive scenarios where some QPS reduction and increased latency are acceptable |
If you have no specific cost reduction requirements, keep the default performance mode. Switch to disk mode only when memory cost is the primary constraint and your business can tolerate reduced query performance. Disk mode requires cluster version 2.6.18 or later.
Performance mode is used by default. Switching the deployment mode does not require rebuilding the index. The mode switch is completed during the load phase by releasing the collection, modifying collection properties, and reloading.
During the switch, the collection is released and reloaded. Query capability for the collection is briefly unavailable during this period. Perform this operation during off-peak hours.
Use the following Python script to complete the switch:
from pymilvus import MilvusClient
CLUSTER_ENDPOINT = "http://xxx-internal.milvus.aliyuncs.com:19530"
TOKEN = "<user>:<password>"
COLLECTION_NAME = "<collection_name>"
def set_diskann_mode(mode: str):
client = MilvusClient(uri=CLUSTER_ENDPOINT, token=TOKEN, timeout=7200)
# 1. Release collection
client.release_collection(COLLECTION_NAME)
# 2. Change deployment mode
client.alter_collection_properties(
COLLECTION_NAME,
properties={"diskann.rabitq_mode": mode},
)
# 3. Reload
client.load_collection(COLLECTION_NAME, timeout=7200)
client.close()
if __name__ == '__main__':
set_diskann_mode("disk") # Switch to disk mode
# set_diskann_mode("perf") # Switch back to performance modeParameter description:
| Parameter | Description |
CLUSTER_ENDPOINT | The access endpoint of the Milvus instance. You can use either a private or public address, both of which must include port 19530. |
TOKEN | The access credential in the format <user>:<password>. |
COLLECTION_NAME | The name of the target collection. |
mode | The deployment mode value: disk (disk mode) or perf (performance mode). |
After the switch is complete, verify the current mode by checking the diskann.rabitq_mode field in the properties returned by describe_collection.
Parameter settings
Adjusting DiskANN parameters allows you to achieve a balance between speed, accuracy, and memory overhead for specific datasets and search workloads.
The current engine does not reject parameters that exceed the recommended value ranges described below. Entering out-of-range values or values that do not satisfy the recommended relationships does not return an error, but may result in abnormal recall rates or query performance. Verify that your values are reasonable before applying them.
Index building parameters
The following parameters affect how the index is built. Adjusting them impacts index size, build time, and search quality.
| Parameter | Description | Values | Tuning Recommendations |
MaxDegree | Controls the maximum number of connections (edges) per data point in the Vamana graph. | Integer. Recommended range: [1, 512]. Default: 56 | Higher values produce a denser graph with better recall, but also increase memory usage and build time. For most scenarios, a value in the range [10, 100] is recommended. |
SearchListSize | The candidate pool size for searching neighbors of each node during index construction. For each node added to the graph, a list of the SearchListSize best candidates is maintained. The search stops when the list no longer improves, and the top MaxDegree nodes are selected as the final edges. | Integer. Must be no less than MaxDegree. Default: 100 | Higher values increase the chance of finding true nearest neighbors for each node, improving graph quality and recall, but significantly increase index build time. Setting the value below MaxDegree degrades graph quality. |
Search parameters
The following parameters affect search behavior. Adjusting them impacts search speed, latency, and resource consumption.
| Parameter | Description | Values | Tuning Recommendations |
search_list | The candidate pool size maintained while traversing the graph during search. | Integer. Default: 100 | Higher values increase the chance of finding true nearest neighbors (higher recall), but also increase search latency. Set this value equal to or slightly greater than the number of results to retrieve (top_k). |
use_refine | Whether to use original vectors for reranking during search. When set to true, original vectors are used for reranking to obtain exact distances. When set to false, only quantized distances are used, and the returned Distance values are approximate. | Boolean. Default: true | For scenarios requiring high QPS, disabling reranking can significantly improve QPS at the cost of some recall reduction. The improvement is particularly significant in high top_k scenarios. |
early_termination_threshold | The early termination threshold for search. The search stops when there is no improvement for N consecutive steps. | Integer. Recommended range: (0, 200]. Default: 30 | Higher values result in more thorough search and higher recall. Lower values trigger earlier termination, improving QPS but reducing recall. |
The search parameters above only take effect when the data volume is sufficiently large. Collections with a small data volume perform exact search directly without going through the ANN index. In such cases, adjusting search_list, use_refine, or early_termination_threshold has no observable impact on recall or returned Distance values. Parameter tuning should be validated on datasets close to production scale.
Having too many segments in a collection noticeably affects query performance. Periodically trigger compaction through the management console or client API to reduce the number of segments.