Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

Learning path · 15 steps

AI System Design: Reliable, Fast and Affordable LLM Apps
  1. 1
    Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
  2. 2
    Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
  3. 3
    Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
  4. 4
    A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
  5. 5
    Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels
  6. 6
    Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
  7. 7
    LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
  8. 8
    Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests
  9. 9
    Cutting p95 and Cost in Half for an LLM App: Read the Bill, Match the Lever, Guard Success
  10. 10
    Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  11. 11
    Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  12. 12
    Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
  13. 13
    Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage
  14. 14
    A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path
  15. 15
    A 500 MB PDF From 50 s to 2 s, the Fast Path: Queue, Status, Streaming and an Acceptance Test That Fails
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. AI System Design

Learning path: AI System Design: Reliable, Fast and Affordable LLM Apps · Step 13 of 15

Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage

A shared cache gave one company's answer to another. In a small synthetic example with two tenants and four documents: filter before ranking, put tenant, user and version in the cache key, write negative tests (with the tenant check removed, 4 of 6 fail), pick pool or silo per segment, and refuse when scope is unavailable.

Chaand Sheikh

·27 November 2026AI System Design

What you will learn

  • Put the tenant filter in the right place: server-side scope, applied before ranking, on every search path
  • Walk a leak through a cache whose key is only the question, and fix the key
  • Write negative tests that can actually see a tenant bug
  • Choose pool or silo per customer segment, and say what still works when each part goes down

Before you start

  • Design a Multi-Tenant RAG Assistant, Part 1
  • Caching for AI Apps

We have our shared assistant on the board, for 500 small businesses and 3 banks (Part 1 covered the requirements and numbers). Now the interviewer pushes: a shared cache just gave one company's answer to another company. Where does your filter sit, and which test proves there's no leak? Pool or silo, for which customers? And what happens when part of the system goes down?

Everything below uses a small synthetic example: two tenants, four documents, no model call.

Five stops

  1. Filter: the search only looks at what this person may see.
  2. Cache: it can leak even when the search is safe.
  3. Prove it, with tests.
  4. Pool or silo.
  5. Outage: take something down and watch.

A search that never asked who

Two companies, acme and bravo, two documents each, all in one pool. Bob works at bravo and asks about the refund policy. The search matches words, so two documents tie for the top, one from each company. Acme's says 30 days, bravo's says 14 days. So Bob could be told 30 days, from another company's policy. Nobody hacked anything. It's a search that never asked who's asking.

unsafe, bob asks: ['a1', 'b1']
scoped, bob asks: ['b1']

The building issues the card

Think of a shared office building. Your card opens your company's floor, and some rooms, like HR, need an extra card. The key part: the building issues the card, you don't write your own. So the scope comes from the server, from the verified login. Never from the request, and never from the model.

Filter before ranking, on both paths Verified login tenant, groups Scope filter before ranking Keyword path filtered Vector path filtered Rank, then model One forgotten path is one leak
Scope decides what the search may look at. Acme's policy never even gets a score when Bob asks.

The filter is enforced before the ranking, inside the search itself. Bob's pool is one document. If your search is hybrid, with a keyword path and a vector path, the filter goes on both.

A leak, walked through the cache

So the search is fixed. Not quite done. Picture a cache whose key is just the question. Ana from acme asks about the refund policy, and her answer is stored under that question. Bob asks the same thing. Same key, so it's a hit, and the search never runs. Bob gets acme's document, even though the search underneath is scoped. That's the incident in the interview question.

cache scoped = False -> ['a1']
cache scoped = True -> ['b1']
hr removed, scoped = False -> ['a2']
hr removed, scoped = True -> []
Plain key against scoped key Plain key "refund policy" Bob hits Ana's entry and gets acme's a1 search never runs Scoped key tenant + user + version + question Bob misses, gets bravo's b1 Ana loses HR: version 1 to 2 old payroll answer unreachable
Synthetic example. A shared answer is only reused inside its scope.

So we put the scope in the key: tenant, user, version and question. Bob's key is different, so he misses and gets bravo's policy. When Ana loses HR access, her version goes from 1 to 2. That's a new key, so her old payroll answer can't be reached. You pay with a lower hit rate. The full cache picture is in Caching for AI Apps.

Which test proves it?

Negative tests: they check what a user must not see. The small example has six, and all six pass. Now take away just the tenant check:

FAILED tests/test_isolation.py::test_no_cross_tenant_leak
FAILED tests/test_isolation.py::test_every_result_is_in_scope
FAILED tests/test_isolation.py::test_cache_key_blocks_other_tenant
FAILED tests/test_isolation.py::test_silo_matches_pool
4 failed, 2 passed in 0.1s

Four fail and two still pass. Those two are worth a look. They only ask about payroll, and only acme has payroll, so they can't see a tenant bug. A green test only covers what it can see. You want a question that matches in both tenants, like "refund policy". And run the tests per tenant, because that's the failure slice you care about.

Pool or silo, per segment

A pool is one index with every tenant inside. A silo is one index per tenant. The same questions were asked both ways for each user, and the results matched, so the silo isn't better on answers here. But with the tenant check removed, the pool returned both companies' documents and the silo returned only acme's. A silo gives you a wall even when there's a bug.

You pay for that with more indexes to run and update, and a pool's safety rests on every query carrying the filter. Cost wasn't measured here, so these are the usual trade-offs, not numbers. For this customer list: pool for the 500 small businesses, and silos for the three banks if their contracts need it.

Walking an outage

Design reasoning, not simulated, so no numbers:

What goes downWhat you do
Model providerFall back to a model this tenant is allowed to use, or say honestly you can't answer now (Fallback Models)
Vector indexThe keyword path still answers, with the same filter; watch quality while it runs that way
CacheTreat every request as a miss; model load jumps, so per-tenant limits have to hold
Login or scope checkRefuse. No scope, no search

Availability can bend. Isolation can't. Set an alarm on any tenant mismatch, and agree the rollback before you need it.

Follow-ups

  • A document's permissions change, not the user's. A key with the user's version won't catch that, so add a version on the document side as well.
  • Can't we tell the model to use only this company's data? No. A prompt isn't an access control, and the model should never receive what the user can't see.
  • How would you spot a leak in production? Record the tenant of every retrieved document, and alert when it doesn't match the request.

A simple rubric

LevelWhat the answer has
Weak"We filter by tenant", and stops
GoodServer-side scope, filter before rank, scoped cache keys
StrongAlso negative tests and permission changes, pool or silo per segment, and what still works in an outage

A judgement guide, not a measurement.

Recap

StopWhat to remember
Scope the searchBob got acme's document because the search had no scope; filtering first fixed it
Scope the cacheTenant, user and version in the key closed the cache leak
Test what must not be seenTenant check removed: 4 of 6 failed; the 2 that passed asked a one-tenant question
Refuse without scopeAvailability bends, isolation doesn't

Try it yourself

Pick a customer with strict rules, and say whether you'd give them a pool or a silo, and why.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in the learning path AI System Design: Reliable, Fast and Affordable LLM Apps · step 13 of 15

Previous
Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
Next post
A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Related posts

Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed

When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.

Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves

A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.

Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys

Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.

A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue

A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.

On this page

  • Five stops
  • A search that never asked who
  • The building issues the card
  • A leak, walked through the cache
  • Which test proves it?
  • Pool or silo, per segment
  • Walking an outage
  • Follow-ups
  • A simple rubric
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Machine Learning Engineer: From First Model to ML Engineer

Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.