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

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.

Chaand Sheikh

·27 November 2026AI System Design

What you will learn

  • Run four checks on every backup model: allowed, fits, user told, rehearsed
  • Walk a fallback chain that skips a model on data residency and on context size
  • Explain why failing loudly beats sending data to the wrong region
  • Rehearse a fallback with a game day and three metrics

Before you start

  • What an LLM can and cannot do
  • LLM Tokens, Context Windows and Cost

When the main model fails, you switch to a backup. That part is easy to say. The hard part is that the backup has to be allowed to take the request, it has to be able to read the whole request, and it has to be tested before the bad day arrives. So it's plan B, but rehearsed.

Everything in this lesson comes from a small simulation. No model provider was called.

Four checks on plan B

Four checks on every backup Allowed? region, data rules Fits? context window User told? flag "degraded" Rehearsed? game day
Every link in a fallback chain has to pass all four.

The bad day, and the interview question

A support assistant is handling a refund email, and it calls the main model. Today that model just hangs, and every call times out. So the app switches to the backup, which nobody has ever tested. Worse, that backup runs outside the region this customer allows. (This scenario is for illustration.)

Design a fallback chain for a customer whose data must stay in the EU, and show how you'd test it before the outage.

Think of a play. The lead actor is your main model. The understudy, who has rehearsed the same lines on the same stage, is a tested backup. An understudy walking on for the first time on the night is a backup nobody tried. And the stage manager telling the audience who's playing tonight is you telling the user. An understudy who never rehearsed isn't a plan.

The chain, link by link

Four simulated models, a European customer and a request of 6,000 tokens. Region and size are checked before any call is made:

Simulated chain, 6,000 tokens primary-eu failed backup-us skipped: residency healthy, big enough small-eu skipped: context 6,000 won't fit mid-eu serves it, 1.3 s degraded = true EU customer, 6,000 tokens. All four models simulated. Healthy doesn't mean allowed
The tempting link is backup-us: healthy and big enough, and the region rule says no.
  • primary-eu is down, so it's marked failed.
  • backup-us is healthy and big enough, but the region rule stops it. That's the tempting one, and we say no.
  • small-eu is in the right region, but 6,000 tokens won't fit, so it's skipped too.
  • mid-eu takes it, in 1.3 simulated seconds. The answer is flagged as degraded, so the app can tell the user and you can count how often it happens.

Here is the simulator's own line for this request (simulated, no real API call):

6000 {'served_by': 'mid-eu', 'degraded': True, 'skipped': [('primary-eu', 'failed'), ('backup-us', 'residency'), ('small-eu', 'context')], 'seconds': 1.3}

When nothing is allowed

Now make the request bigger: 10,000 tokens, same outage. Primary has failed, the US model is blocked, and the two EU models are too small. So nothing serves it:

10000 {'served_by': None, 'degraded': True, 'skipped': [('primary-eu', 'failed'), ('backup-us', 'residency'), ('small-eu', 'context'), ('mid-eu', 'context')], 'seconds': 0.9}

That's the right result. Failing loudly beats quietly sending data to the wrong region. So what does the user see? A plain reply with no model at all, one that says we can't answer this right now. That's your last resort. The simulation only reports the failure, so the plain reply is design advice, not something it tested.

The quiet trap: the backup reads less

For illustration, say a refund needs five pieces of evidence: the email, the order, the policy, past refunds and the limit rule. The backup has a smaller context window, which is how much text a model can read at once. Say it has room for three.

Five pieces, room for three email order policy past refunds limit rule backup has room for three cut to fit: dropped, no error For illustration only
The answer still looks normal. It's just worse.

If you just cut to fit, two pieces fall away. There's no error. So check the fit before you switch. Too big is just another no.

Rehearse it with a game day

A game day is a planned drill where you break the main model on purpose. Then you check who served each request, whether it stayed in the region, and whether degraded was set. And you measure three things (these are what you'd watch; the lesson has no drill result):

MetricWhat it tells you
Fallback rateHow often the backup answers
Quality gapThe backup's score against the main model's, on a fixed test set
Failover timeFrom the first failure to the first backup answer

If you haven't measured it, you don't have it. The fixed test set is the same idea as in Why You Cannot Ship Without an Eval.

Follow-ups and a simple rubric

  • Why not fall back to any healthy model? Because healthy doesn't mean allowed, and it may not fit.
  • Do you fall back when the model refuses? Usually no. A refusal isn't an outage, so you don't go shopping for a model that says yes.
  • What's the last resort? A plain reply with no model, one that says so.
LevelSounds like
Weak"We have a backup."
GoodAn ordered chain, a region rule and a check on the fit
StrongAlso flags degraded answers, ends with a plain reply, and rehearses it with a measured game day

The rubric is a guide for practice, not a guaranteed result. Fallbacks usually sit next to retries: see Retries and Backoff for when to retry the same model first.

Recap

IdeaWhat to remember
Every linkAllowed for this data, and the request fits
6,000 tokens (simulated)Served by mid-eu, flagged degraded
10,000 tokens (simulated)Nobody serves it; fail loudly, plain reply
Before the outageGame day: fallback rate, quality gap, failover time

Try it yourself

Imagine mid-eu had room for 10,000 tokens. Who serves that big request now, and is it still flagged degraded?

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

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

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

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.

Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels

A support bot's cache can hit 97% of requests and still answer only 52% correctly. Four cache layers, the key each one needs, how a document delete has to travel through all of them, and a 200-request simulation that puts hit rate next to correct answers.

On this page

  • Four checks on plan B
  • The bad day, and the interview question
  • The chain, link by link
  • When nothing is allowed
  • The quiet trap: the backup reads less
  • Rehearse it with a game day
  • Follow-ups and 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.