Multi-Tenant RAG
In this article
- Choose between a dedicated index per tenant, a namespace per tenant and one shared table with a mandatory tenant filter, from isolation strength, cost and operations.
- Explain why the tenant must come from the signed-in session and be enforced by the database, so a forged tenant_id in a request changes nothing.
- Stop one tenant's bulk import from slowing another tenant's searches with a per-tenant ingest quota and query rate limit.
- Write a cross-tenant leakage test and a noisy-neighbor load test that a shared index must pass.
- Terms defined here: tenant, tenant isolation, noisy neighbor.
Overview
You sell one product to many companies, and their documents live in one search system. A customer of company A asks a question, and the answer quotes a help page of company B. Nobody broke in; a filter was missing on one path. How do you share a search index and still prove one company cannot read the other, or slow it down?
Brightline, a made-up home-internet provider, runs a support assistant that searches its help pages, cut into short chunks, and sends the best 3 to the model with each question. Brightline also offers the assistant to 300 smaller internet providers that resell its service, each with its own help pages and customers. You will pick the storage shape for them, wire the boundary so a request cannot move it, and write the two tests that prove it holds.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- What a tenant is
- Three ways to draw the line
- Choosing for 300 small partners
- Where tenant_id comes from
- The noisy neighbor
- Proving one tenant cannot read another
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions