Skip to main content

Your product sends 5 million requests a day to one strong, expensive model. Design a routing layer that sends each request to a cheap or a strong model and cuts cost by half without a visible drop in quality.

System design · Pro 2

Short answer

Clarify the request types and what quality means for each. Label real traffic, then route with rules or a small classifier: easy requests to the cheap model, hard or risky ones to the strong model, with escalation when the cheap answer fails a check. Evaluate each route offline, roll out gradually, and monitor cost, latency and quality per route.

Deeper answer

Start with data: sample real requests, group them by task, and run both models on an evaluation set for each group. Often most traffic is simple, such as classification, extraction or short answers, where the cheap model matches the strong one. That tells you how much can move and sets the quality bar.

Design: a router in front of the models. Begin with rules on task type and input length, then add a small, fast classifier trained on labelled examples of where the cheap model failed. A cascade is a second option: try the cheap model, run a quick check such as schema validation or a confidence signal, and escalate to the strong model on failure. The cascade costs extra latency and money on escalated requests, so it suits traffic where most requests pass.

Risks: silent quality loss on a small group of users, and router mistakes on new request types. Send uncertain cases to the strong model by default. Measure cost per request, latency and quality per route, keep a fallback when a provider fails, and re-run the evaluation whenever a model or prompt changes.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Grow an AI app in layers: context, guardrails, routing, caching and agents

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.