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 12 of 15

Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract

A support assistant for 500 small businesses and 3 banks. Requirements first, then the arithmetic in the open (38,000 tickets a day, 528,000 tokens a minute at an assumed peak), a first diagram where the tenant travels with every request, and a contract written before the test set is opened.

Chaand Sheikh

·27 November 2026AI System Design

What you will learn

  • Explain the two failures of a shared platform: one tenant seeing another's answer, and one tenant using up everyone's limit
  • Ask for requirements and promises (SLOs) before drawing any boxes
  • Do a capacity estimate out loud, from tickets a day to tokens a minute at peak
  • Write a release contract: dataset, baseline and a bar, set before you see results

Before you start

  • The ML System Design Framework
  • The RAG Pipeline Explained

Here's a system design question you can use again and again: design a support assistant that answers from each company's own documents, for 500 small businesses and 3 banks. The hard part isn't the model. The hard part is the sharing. So before any boxes, we ask who's using it and what we've promised them. Then we do the arithmetic in the open, and write down what must be true before it ships.

Every input here is assumed, for illustration. The few results come from small simulations with synthetic tickets, and each one says so.

One building, many flats

Each customer on a shared system is called a tenant. Think of a big apartment building:

  • The flats are your tenants. Each family lives its own life.
  • The plumbing is the shared platform. That's why this is cheap to run. But if one family runs every tap at once, the others lose their pressure.
  • The lock on each door is isolation, so nobody walks into the wrong flat.

Sharing saves money, and it creates two failures you should name in the first minute.

The leak and the noisy neighbour Failure 1: a leak Tenant A asks Shared cache Key has no tenant in it, so tenant B gets A's answer Failure 2: noisy neighbour One shared token limit, full One tenant's batch job fills it, everyone else gets a 429
Nobody hacked anything in failure 1: one key was missing one field. In failure 2, the other customers did nothing wrong.

A 429 is the provider's "too many requests, slow down" reply. A token is a small piece of text, and providers limit how many you use each minute.

In a small simulation with assumed traffic and an assumed limit, one bad minute looks like this: a bank sends 300 requests and fifty small shops send 4 each. The shared limit fills up, and 76 of the shops' 200 requests get turned away. That's why the sharing goes in your requirements.

The order of the answer

Say it in this order, out loud: requirements (who uses it, what have we promised), numbers (roughly how big is it), first diagram (one request moving through), and the contract (how we decide whether it ships). It's the same shape as the ML system design framework, applied to a shared AI system.

Requirements: who, how much, what promise

All inputs assumed, for illustration:

WhoAssumed volumeTickets a day
500 small businesses40 tickets a day each20,000
3 banks6,000 tickets a day each18,000

So three customers send 47.4% of all tickets. Then the promises. An SLO, a service level objective, is simply a target we commit to:

  • 95% of answers within 4 seconds (that's the p95; see Latency Math).
  • 99.5% availability.
  • Zero cross-tenant leaks. That one is just zero.

Every number here is an assumption. They're targets until something measures them, and you should say that.

A rough estimate, out loud

For illustration, with assumed inputs: tickets land in 600 busy minutes, the peak minute is 4 times the average, and the provider limit is 600,000 tokens a minute.

From tickets a day to tokens a minute 38,000 tickets a day 63.3 / min over 600 minutes 253.3 / min peak = 4 × average 528,000 tokens / min Assumed limit 600,000 tokens a minute: only 72,000 spare at peak All inputs assumed, for illustration
Nobody plans for the average. The peak minute is what shapes the design.

Each ticket costs tokens, a bit more for a bank, and at the peak that comes to 528,000 tokens a minute. Against an assumed 600,000 limit, 72,000 are spare. That's not much room.

The first diagram, with the tenant travelling along

Follow one request: gateway → limiter → cache → retrieval → model.

  • The gateway works out who the tenant is. From here on, the request carries that tenant with it.
  • The limiter checks this tenant's share before anything is spent.
  • Then the cache, retrieval over this tenant's documents, and the model writes the answer.

Here's what the limiter costs, in the same simulated bad minute:

shared pool   {'bank_ok': 157, 'bank_429': 143, 'small_ok': 124, 'small_429': 76, 'tokens_used': 600000}
20% per tenant {'bank_ok': 50, 'bank_429': 250, 'small_ok': 200, 'small_429': 0, 'tokens_used': 480000}

A cap of 20% per tenant takes the turned-away shop requests from 76 to 0. But the bank drops from 157 requests served to 50, and 120,000 tokens sit unused. Every shared box needs to know the tenant, and every fix costs something. Say who pays.

The cache needs the tenant too. In a stand-in simulation (no model call), a key that leaves the tenant out serves one company's "30 days after delivery" to another, with 1 model call. A key with the tenant gives the second company its own "14 days after purchase", with 2 model calls. Part 2 walks that leak in detail: Isolation, Cache and Failures.

The contract: dataset, baseline, bar

How do we know it's any good? We agree before we build.

  1. Dataset. In the small simulation: 8 documents, 6 tickets to work on, and 6 test tickets kept locked, all synthetic.
  2. Baseline, the simplest thing that could work: take the tenant's first document, no ranking. Right on 1 ticket in 6, 0.167. Filtering by tenant and ranking by shared words gets 5 in 6, 0.833.
  3. The bar, written in advance: at least 0.6 on test, a gain of at least 0.3, and zero leaks.
dev baseline {'hit_at_1': 0.167, 'leaks': 0}
dev retrieve {'hit_at_1': 0.833, 'leaks': 0}
test retrieve {'hit_at_1': 1.0, 'leaks': 0}
{'checks': {'quality': True, 'gain': True, 'leaks': True}, 'ship': True}

We open the test set once: 1.0, six out of six, zero leaks, so it ships. Read that honestly, though. One ticket shares no words with any document, so every score ties, and the first document just happened to be right. Six tickets is a small set, so don't quote that 1.0 to anybody.

After it ships

This part wasn't simulated, so there are no numbers, just the plan. Watch the same numbers per tenant, because an average can hide one customer having a bad week. Slice failures by tenant, topic and kind of question. Set alarms on the promises; any cross-tenant leak raises one straight away. Agree in advance how to roll back. And put bad answers back into the dataset.

Follow-ups

  • Your estimate is off by a factor of two. What changes? The peak passes one million tokens a minute, over the limit we assumed. You'd need a bigger limit, or a queue for batch work (see Back Pressure).
  • The customer wants fine-tuning first. Not before a baseline. Without one, you can't tell whether fine-tuning helped.
  • Your test score is 1.0. Do you believe it? No. It's six tickets and one tie; I'd want a bigger locked set.

A simple rubric

LevelWhat the answer has
WeakJumps to models and vector stores, with no numbers
GoodRequirements, an estimate, and the tenant running through the diagram
StrongAlso labels its assumptions, names what each fix costs, sets a baseline, and doubts its own best score

The rubric is a judgement guide, not a measurement.

Recap

StepWhat to say
RequirementsWho the tenants are, and the promises: p95 4 s, 99.5%, zero leaks (assumed)
Numbers38,000 tickets a day to 528,000 tokens a minute at peak, every input labelled assumed
DiagramThe tenant travels with the request through every shared box
ContractDataset, baseline and bar, written before the results

Try it yourself

Double the banks' traffic on paper, and say which promise breaks first.

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 12 of 15

Previous
Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
Next post
Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage

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

  • One building, many flats
  • The order of the answer
  • Requirements: who, how much, what promise
  • A rough estimate, out loud
  • The first diagram, with the tenant travelling along
  • The contract: dataset, baseline, bar
  • After it ships
  • 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.