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

LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic

Send easy tickets to a small model and the bill drops from 21.39 to 4.31 units per solved ticket, while refund disputes fall from 0.93 to 0.64. A 1,200-ticket simulation compares rules, a classifier and a cascade on cost per win, the confidence dial, and a per-topic gate.

Chaand Sheikh

·27 November 2026AI System Design

What you will learn

  • Start a routing design from an all-large baseline and a hard rule for restricted data
  • Compare rules, a classifier and a cascade on cost per successful ticket, not cost per call
  • Treat the escalation threshold as a dial and pick it on separate tickets
  • Prove a router topic by topic against a limit set in advance, then keep sampling in production

Before you start

  • LLM Tokens, Context Windows and Cost
  • Why You Cannot Ship an LLM Feature Without an Eval

Here's a senior interview question: 70% of your support tickets are simple. Design a router that cuts cost without a measurable quality drop, and show the evaluation that proves it. The 70% is the question's premise. We'll compare three ways to route, see what sends a ticket up to the large model, and prove it topic by topic. The tickets and models come from a small simulation, and costs are illustrative units, not prices: one unit for a small-model call, twenty for a large one.

Four steps

  1. A baseline: every ticket goes to the large model, so you have something to beat.
  2. Pick a way to route.
  3. Pick the signal that sends a ticket up.
  4. Prove it per topic against that baseline, because an average hides things.

The triage nurse

A hospital has one senior specialist, expensive and always busy. Not every patient needs her. Some signs go straight up: chest pain goes to the specialist. That's rules. Otherwise a triage nurse looks at you for a minute and makes a call before any treatment starts. That's a classifier. Or a junior doctor actually sees you, and if she's unsure, she calls the specialist. That's a cascade.

Rules and the nurse decide up front; the junior decides after doing some of the work. And the hospital's real worry is the patient sent home with the wrong call. That's what we have to catch.

The bill drops, and one topic falls

In a simulation with 1,200 tickets, sending everything to the large model costs 21.39 units per solved ticket. Call that cost per win. Now a cascade with a low confidence bar, 0.5, so the small model keeps most tickets. Cost per win falls to 4.31. It looks like a huge success. Then look at topics (open tickets only):

A cheap cascade hides two topics that collapse Password reset Refund dispute Account recovery 0.97 all-large 0.93 cascade 0.93 all-large 0.64 cascade 0.88 all-large 0.57 cascade Simulated, open tickets, confidence bar 0.5
The hard tickets went to the small model, and the customers on those topics paid for the saving.

Rules, classifier or cascade

Now the three routes with a sensible bar (0.7 for the cascade). One rule comes first for all of them: restricted tickets stay on the small private model, and if it's unsure, they go to a human.

restricted tickets: 158 of 1200
all-large   violations= 158 human=   0
rules       violations=   0 human=  70
classifier  violations=   0 human=  70
cascade     violations=   0 human=  85

The all-large baseline broke that rule 158 times. Here is the comparison. Note the two quality columns: the simulator's table prints overall quality on all 1,200 tickets, and the numbers people quote for routing are quality on open (non-restricted) tickets.

simulated tickets: 1200 (cost in units)
route       quality    cost  per win  large
all-large     0.935   24000    21.39   1.00
rules         0.805    5380     5.57   0.18
classifier    0.833    7698     7.70   0.28
cascade       0.863    9100     8.79   0.33
RouteCost per win (units)Quality, open ticketsQuality, all tickets
All large21.390.940.935
Rules5.570.850.805
Classifier7.700.880.833
Cascade (bar 0.7)8.790.930.863

Rules are cheapest, and the cascade is closest to the baseline. Its cost per win is about 59% below all-large. That saving comes from what we assumed, like the large model costing twenty times the small one. Change that, and the saving moves.

The signal that sends a ticket up

In the cascade, the signal is the small model's confidence, and it works like a dial:

The confidence bar is a dial back towards all-large bar 0.5 bar 0.7 bar 0.9 12% to large, 4.31 per win 33% to large, 8.79 per win 72% to large, 18.33 per win Simulated; all-large is 21.39 per win (illustrative units)
Turn the bar up and you almost dial your way back to all-large.

Confidence only helps if right answers score higher than wrong ones, and the simulation assumed that. A production model can be confident and wrong. So measure it, and add other signals: no document found, a tool that failed, or a customer asking again. And pick the bar on separate tickets, not the ones you report on.

Prove it against all-large

Each route is compared with all-large, overall and per topic, against a limit chosen beforehand:

rules       FAIL: overall -0.09, invoice copy -0.08, password reset -0.09, account recovery -0.27, api error trace -0.23
classifier  FAIL: overall -0.06
cascade     pass

Rules miss the limit on five lines. The classifier misses it once, overall, by about 0.06. The cascade passes. But read that carefully: on open tickets it's still 0.93 against 0.94, and API error traces go from 0.85 to 0.77. So don't say "no quality drop". Say it stayed inside a limit you chose before you saw results. The same idea of a gate written in advance is in Regression Testing an LLM Bot in CI.

Catching a regression in production

This part is a design answer; it wasn't simulated. Tickets change after launch, so:

  • Log every routing decision with the topic, the signal and the model.
  • Send a small sample of the tickets the small model kept to the large one too, and compare.
  • Watch customer satisfaction per topic, not just overall.
  • Watch the escalation rate. A sudden move means something changed, even if the average looks fine.
  • Keep a flag that sends one topic back to the large model, so one bad topic doesn't mean turning the whole router off.

The follow-ups

  • Classifier or cascade? A classifier spends nothing before deciding, but it's a guess. A cascade sees an answer, but a hard ticket pays twice, 1 unit and then 20, and waits longer. The simulation doesn't measure time, so say that.
  • A topic turns up that you never evaluated. Send it to the large model until you have cases for it.
  • Why cost per win, not cost per call? Because a cheap wrong answer isn't cheap.
LevelWhat the answer has
Weak"Send the easy tickets to the small model and save money"
GoodAn all-large baseline, restricted data handled first, routes compared on cost per win
StrongAlso checks every topic, names the signal and how the bar is picked, and labels the saving as depending on its assumptions

What to do when the large model is down altogether is a different pattern: Fallback Models.

Recap

IdeaWhat to remember
BaselineAll-large first, plus a hard rule for restricted data
RoutesRules, classifier, cascade, each scored on cost per win
SignalA dial; pick it on separate tickets and add signals besides confidence
ProofTopic by topic, inside a limit set first, then keep sampling in production

Try it yourself

Pick a product you use that gets easy and hard requests. Name the signal you'd trust to send a request up to the bigger model, and how you'd find out it was wrong.

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

Previous
Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
Next post
Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests

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

  • Four steps
  • The triage nurse
  • The bill drops, and one topic falls
  • Rules, classifier or cascade
  • The signal that sends a ticket up
  • Prove it against all-large
  • Catching a regression in production
  • The follow-ups
  • 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.