May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
2 system design questions lean on this idea. Each walks through the full answer.
AI Engineering · Core
Free preview: the first 2 parts of this 13-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by card or PayPal
See the Generative AI and Agentic AI courseread the rest of this lesson in
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by card or PayPal
See the Generative AI and Agentic AI coursein Core
This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime AccessFoundation lessons of this course are free, no payment needed. Try them now
A team ships a retrieval-augmented chatbot over their help center. In the demo it is flawless: ask a question, watch it pull the right article and answer in grounded, confident prose. Everyone claps. Then it goes live to real traffic and the trouble starts. The first spike of users pushes response times past ten seconds. The monthly cloud bill arrives and the GPU line item is four times the estimate. Someone updates the refund policy on Tuesday, and the bot keeps quoting the old one through Friday. During a busy afternoon the model server falls over, and instead of degrading, the whole feature returns error pages.
None of that is a problem. The retrieval works, the reranker works, the model answers well when it answers at all. What broke is everything around the model: how it is served, how fast it responds under load, what each answer costs, how the index stays current, and what happens when a dependency fails. That gap between a notebook that works and a service that stays up is the entire subject of this lesson.
A separate chapter covers what RAG is and why retrieval grounds a model. This one assumes you already have that pipeline and asks the harder question: how do you operate it, at scale, for months, without it becoming slow, expensive, stale, or unreliable?
We will treat the RAG plus LLM feature as what it really is in production, a distributed system with a budget, a cost model, a freshness contract, and a reliability target. By the end you will be able to read a live RAG service the way an on-call engineer does: know where the time goes, where the money goes, what breaks, and which lever fixes it.
The first thing to get straight is that a production system is not one program. It is two, and they run on completely different clocks. The offline lane turns documents into a searchable index; it runs on a schedule or when documents change, and it is allowed to be slow. The online lane answers live questions on every request, and it lives or dies by a latency budget. They touch at exactly one place, the shared vector store, and the single rule that keeps them consistent is that both lanes must embed with the same pinned model, or the query vectors and the document vectors stop being comparable.

Drawing that boundary is the design decision everything else hangs off. Offline work can be slow, cheap, retried on failure, and scaled with ordinary batch infrastructure. Online work must be fast, cheap per call, and must never hang, because a hung request is a user staring at a spinner. The classic mistake that wrecks a RAG service is collapsing the two: re- documents on the request path, or serving queries against an index that no offline job keeps up to date. Keep them as two independently deployed, independently scaled services that happen to share a database, and each one becomes something you can reason about, monitor, and scale on its own terms.
Notice where the expensive box sits. In the online lane, retrieval and are cheap and fast. The large language model is the slow, costly, fragile component, and almost every operational decision in the rest of this lesson is really a decision about how to call that model less often, serve it more efficiently, or survive it when it fails.