8 min read

Beyond the Memory Wall: Architecting Multi-Tenant Hierarchical Storage for Real-Time Vector Search

Multi-Tenant Hierarchical Storage for Real-Time Vector Search

Beyond the Memory Wall: Architecting Multi-Tenant Hierarchical Storage for Real-Time Vector Search

The “Gold Rush” of Generative AI has a dirty secret that every infrastructure engineer eventually hits: Vector databases are obscenely expensive.

In the early days of the RAG (Retrieval-Augmented Generation) hype, we were all happy to shove a few thousand embeddings into a FAISS index or a managed service and call it a day. But as we transition from toy demos to enterprise-scale production, the math changes. When you’re managing billions of high-dimensional vectors—representing everything from multi-modal user behavior to trillion-token document repositories—the “put it all in RAM” strategy hits a brick wall of economic reality.

If you are building a multi-tenant SaaS platform where thousands of customers each have their own massive datasets, providing sub-50ms latency while maintaining a sustainable COGS (Cost of Goods Sold) is the ultimate engineering balancing act.

Today, we’re going deep into the architecture of Hierarchical Storage Management (HSM) for Vector Databases. We’ll explore how to break the dependency on massive RAM clusters by tiering data across NVMe, persistent memory, and object storage, all while ensuring that “Tenant A” doesn’t starve “Tenant B” of IOPS.


To understand why we need HSM, we have to look at the anatomy of a vector. A typical OpenAI text-embedding-3-small vector has 1,536 dimensions. Using float32, that’s 6KB per vector.

  • 1 Million Vectors: ~6GB (Manageable)
  • 1 Billion Vectors: ~6TB (This is where the pain starts)

In a traditional HNSW (Hierarchical Navigable Small World) index—the gold standard for speed—you aren’t just storing the vectors; you’re storing a complex graph of pointers. This graph overhead adds another 20-50% to your memory footprint. To run a billion-vector search in pure RAM, you’re looking at a cluster costing tens of thousands of dollars per month.

For a multi-tenant environment, this is a death sentence for margins. Not every tenant’s data is “hot.” The CEO’s emails from 2014 shouldn’t be sitting in expensive DDR5 RAM, but they still need to be searchable in a heartbeat.


The HSM Blueprint: A Three-Tiered Approach

The goal of a Hierarchical Storage Management system is to create an illusion: The capacity of S3 with the latency of RAM. To achieve this, we divide our storage into three distinct tiers:

1. The Hot Tier (L1): In-Memory HNSW

This tier handles the most recent or frequently accessed data. We use a high-connectivity graph index like HNSW here.

  • Media: RAM / Intel Optane.
  • Latency: < 10ms.
  • Optimization: We use Product Quantization (PQ) to compress vectors. By representing 1,536-dimensional vectors as short codes, we can reduce the memory footprint by 10x-20x, albeit with a slight hit to recall accuracy.

2. The Warm Tier (L2): DiskANN on NVMe

This is the “sweet spot” for modern vector architecture. Inspired by Microsoft’s DiskANN research, this tier stores the full-precision vectors on local NVMe SSDs while keeping a highly compressed “search graph” in memory.

  • Media: Local NVMe (AWS i4i instances or similar).
  • Latency: 15ms - 50ms.
  • Optimization: SSD-resident graphs. Instead of loading the whole vector during the graph walk, we only fetch the vector data from the disk at the very last stage of the search.

3. The Cold Tier (L3): Compressed Blobs on Object Storage

This is for the massive tail of historical data.

  • Media: S3 / GCS / Azure Blob.
  • Latency: 200ms - 2s.
  • Optimization: Data is partitioned by Tenant ID and Time. We use inverted file indexes (IVF) here rather than graphs, as they are easier to serialize and stream from object storage.

Solving the Multi-Tenancy Conundrum

In a multi-tenant vector database, you face the “Noisy Neighbor” problem on steroids. Vector search is CPU and IOPS intensive. If Tenant A triggers a massive re-indexing of a million documents, Tenant B’s real-time search shouldn’t lag.

Logical vs. Physical Isolation

We approach multi-tenancy through a Cell-Based Architecture.

  • Small Tenants: Co-located on shared nodes. Their indexes are stored as separate namespaces within a single process. We use cgroups to limit the maximum CPU/RAM a single namespace can consume.
  • Large Tenants: Promoted to dedicated “Siloed Nodes.”

The Tenant-Aware Router

The brain of the system is a high-performance router (often written in Rust or Go) that maintains a metadata map of where every tenant’s data lives across the tiers.

// A simplified view of a Tenant Routing Decision
pub async fn route_query(tenant_id: TenantId, query_vector: Vector) -> QueryResult {
    let metadata = registry.get_tenant_metadata(tenant_id).await;

    match metadata.storage_tier {
        Tier::Hot => hsnw_executor.search(tenant_id, query_vector).await,
        Tier::Warm => diskann_executor.search(tenant_id, query_vector).await,
        Tier::Cold => {
            // Check if we should hydrate to Warm tier first
            if metadata.access_frequency > THRESHOLD {
                tier_manager.promote_to_warm(tenant_id).await;
            }
            s3_executor.search(tenant_id, query_vector).await
        }
    }
}

Technical Deep Dive: Adapting HNSW for Disk

The standard HNSW algorithm is fundamentally “pointer-heavy.” In RAM, following a pointer is cheap. On an SSD, every pointer hop is a potential random I/O request. If your graph walk requires 100 hops, and each hop is an SSD read, your latency will skyrocket to 100ms+.

The Vamana Graph (DiskANN)

To make HSM work, we replace HNSW in the Warm Tier with Vamana. Unlike HNSW, which has a hierarchical structure, Vamana is a flat graph designed with a smaller “diameter.”

The Trick: We optimize the graph for Sequential I/O. During the indexing phase, we layout the vectors on the disk such that vectors that are close in the graph are physically close on the SSD blocks. This allows us to use io_uring in Linux to pre-fetch neighbor vectors in a single syscall, drastically reducing the number of I/O wait cycles.

Bit-Packing and SIMD

When we move to the Warm tier, we can’t afford to waste a single bit. We use SIMD (Single Instruction, Multiple Data) instructions (AVX-512 or ARM Neon) to calculate distances. While the vectors are stored on disk, the distance calculations happen in the CPU registers. By using Int8 Quantization instead of Float32, we can fit 4x more data in the CPU cache lines, making the “Warm” tier feel almost as fast as the “Hot” tier.


Scaling the Compute: The Separated Architecture

Modern cloud-native architecture demands the Separation of Storage and Compute. In a vector HSM environment, this is critical because indexing is expensive, but searching is (relatively) cheap.

We utilize a “Log-Structured” approach:

  1. Ingestion Service: Receives new vectors and writes them to a Write-Ahead Log (WAL) on NVMe.
  2. Indexing Workers: Asynchronous fleet of GPU-enabled workers that pull from the WAL, build the HNSW/Vamana graphs, and push the shards to the HSM layers.
  3. Query Engine: Stateless pods that pull index shards from the HSM layers into their local caches to serve queries.

By decoupling these, we can scale the Indexing Workers (GPU-heavy) independently of the Query Engine (CPU/RAM-heavy). If a tenant suddenly uploads 10 million vectors, our search latency doesn’t budge because the indexing happens on a separate, auto-scaling cluster.


Managing the Lifecycle: The “Hydration” Strategy

In a multi-tenant HSM, data isn’t static. We need a “Data Mover” daemon that constantly evaluates the utility of every shard.

  • Eviction: If a tenant hasn’t queried their “Hot” index in 24 hours, the system flushes the full-precision vectors to the Cold tier (S3) and keeps only a tiny “Bloom Filter” or a high-compression PQ index in RAM to check for existence.
  • Pre-warming (Hydration): Using predictive analytics, we can anticipate when a tenant might need their data. For instance, if a B2B SaaS tenant’s users log in at 9:00 AM EST, the HSM starts “hydrating” their indexes from S3 to NVMe at 8:45 AM.

Zero-Copy Transfers

To make these moves efficient, we use Zero-copy I/O. When moving data from the Warm (NVMe) to the Cold (S3) tier, we avoid copying data into user-space memory. Instead, we use sendfile or specialized kernel bypass techniques to pipe data directly from the disk controller to the network interface.


The “Hype” vs. The Reality

You’ve likely seen the headlines: “Vector Databases are the new Oracle!” or “Native Vector Search in Postgres makes standalone Vector DBs obsolete!”

The reality is more nuanced. While adding a vector column to pgvector is great for small apps, it lacks the Hierarchical Storage capabilities required for true multi-tenancy at scale. A standard relational database tries to cache pages in a buffer pool. But vector search doesn’t access “pages”; it traverses a high-dimensional graph.

The “hype” focuses on the capabilities (search by meaning!), but the “substance” lies in the infrastructure (how do I do this for 10,000 customers without going bankrupt?). The real engineering winner isn’t the one with the best search algorithm; it’s the one with the most efficient IOPS management and storage tiering.


Infrastructure Checklist for HSM Vector DBs

If you’re building this today, here is your high-level tech stack:

  • Language: Rust (for memory safety and zero-cost abstractions) or C++. Avoid GC-heavy languages like Java for the core engine to prevent stop-the-world pauses during massive graph traversals.
  • I/O: io_uring. You need asynchronous, non-blocking I/O to handle the “Warm” tier efficiently.
  • Orchestration: Kubernetes with Local Persistent Volumes for the NVMe tier.
  • Compression: Zstandard (zstd) for metadata and Product Quantization for the vectors themselves.
  • Networking: gRPC with Protobuf for low-latency communication between the Router and the Query Nodes.

The Road Ahead

Architecting for the billion-vector scale in a multi-tenant world is fundamentally a game of caching and scheduling. By embracing Hierarchical Storage Management, we move away from the “RAM or Bust” mentality and toward a more sustainable, tiered approach.

The next frontier? Hardware-accelerated HSM. We are already seeing the emergence of CXL (Compute Express Link) which will allow us to pool memory across nodes, and NVMe-over-Fabrics (NVMe-oF) which will blur the lines between “Warm” and “Cold” storage.

In the AI era, data is the gravity. But with a well-architected HSM, that gravity doesn’t have to pull your infrastructure costs into a black hole.

Stay tuned for our next deep dive, where we’ll look at the performance benchmarks of Vamana vs. HNSW on the latest AWS i4i.16xlarge instances.


More to explore

Keep diving in