"Add RAG to your SaaS" is the easy part. The hard part nobody warns you about: in a multi-tenant product, retrieval is a security boundary. If tenant A's query can surface tenant B's documents, you don't have a search bug — you have a data breach with a latency SLA. This post is the design I use, in two phases, and the failure modes that decide which one you actually need.
Every managed vector/RAG service forces a choice. Both are legitimate; they fail in different places.
| Phase 1 — siloed stores | Phase 2 — shared store + metadata | |
|---|---|---|
| Layout | One store per tenant; user_id → store_name map in your datastore | One shared store; every doc tagged customMetadata:{tenant_id} |
| Retrieval call | Attach only that tenant's store per request | Always pass metadata_filter set server-side |
| Isolation strength | Physical — impossible to cross | Logical — depends on your filter never being bypassed |
| Scaling ceiling | Provider project quotas (per-store limits, total project cap) | Index size, metadata-filter latency |
| GDPR delete | Drop the whole store — clean | Delete by metadata — eventual consistency |
| Best for | Up to a few thousand tenants | 10k+ tenants, cost pressure |
Tenant scope is enforced in the request builder, never trusted from the client.
In the shared-store design, the single most dangerous line of code in your system is
a metadata_filter assembled from a client-supplied parameter. One missing
parameter and every tenant's documents are retrievable. The filter must be constructed
server-side from the authenticated session — the client can narrow within their
own scope, never widen it.
Managed RAG billing has non-obvious multipliers that determine your unit economics before you write a line of product code. The facts I plan around (verify against your provider's current docs — these change):
Worked example: with a 40MB-per-user cap and a 1TB project quota, your ceiling is ~8,000 full-cap tenants — not the 100k your marketing page hopes for. Per-user limits (doc count, file size, total bytes) are therefore the cost control, and they should differ by plan tier while isolation stays identical for everyone.
?tenant_id=.
Trivially exploitable. Fix: filter built from session, client params can only narrow.Multi-tenant RAG is where "it works in the demo" goes to die. The demo has one user; production has adversarial neighbors. The design that survives is boring: scope enforced server-side, quotas as first-class limits, deletion as a contract, and a migration path between isolation architectures that doesn't change your API. Get those four right and the retrieval quality questions — chunking, reranking, hybrid search — are the fun part you actually get to spend time on.