Compare namespace-per-tenant against single-shared-index-with-tenant-filter for a B2B RAG product serving 5000 customers.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A B2B RAG product has 5000 customer tenants ranging from 10 documents to 500k documents each. Compare the two main multi-tenancy patterns for the vector layer (namespace-per-tenant vs single shared index with a tenant_id filter). Cover correctness, cost, noisy neighbor risk, and the small-tenant cold start problem.
Namespace-per-tenant gives strong isolation but pays per tenant overhead, hurting small tenants. Shared-index-with-filter amortizes cost but hits the filter broken recall HNSW pitfall and noisy neighbor risk.
Imagine you run a self-storage facility, and 5000 small businesses are renting space in your search system. **Option A: a separate room per tenant.** Their stuff is totally separated; nobody can peek; you can clear out a tenant by emptying their room. But you pay rent on 5000 rooms, and many of them are nearly empty. **Option B: one giant warehouse with everyone's stuff mixed and tagged with stickers.** Cheaper rent overall, but when a small tenant asks for their stuff, you have to search through the whole warehouse looking for their sticker, and sometimes the warehouse layout makes you miss their items. **The answer in real life:** put your three biggest tenants (who fill the warehouse) in their own rooms anyway, and pool the other 4997 into the shared warehouse.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: walk through both pure patterns + filter broken recall pitfall + heavy-tail distribution argument + layered hybrid recommendation + 2026 vendor primitives.
| Concern | Namespace per tenant | Shared index + filter | Hybrid |
|---|---|---|---|
| Isolation | Strong | Filter-only (not a security boundary) | Strong for whales, filter for tail |
| Per tenant cost | Constant overhead (bad for small tenants) | Amortized | Right-sized per tier |
| Cold-start | Bad for tiny tenants | Non-issue | Solved per tier |
| Noisy-neighbor | Bounded per index | Cross-tenant interference | Bounded for whales, pooled for tail |
| GDPR delete | Drop one collection | Scan + tombstone (expensive) | Drop for whales, scan-filtered for tail |
| HNSW recall safety | Always good | Filter-broken-recall risk | Good for whales; mitigated by filterable HNSW for tail |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Picking 'shared index with tenant_id filter' as universally right because it sounds efficient, without noticing that HNSW with a selective metadata filter is exactly the configuration that returns fewer than K results.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.