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...
AI Engineering · Serving And Inference
Free preview: the first 2 parts of this 35-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 Serving And Inference
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
Let me start in a small library.
The library has one long shelf near the front desk. Readers ask for books, and the librarian fetches them. A book on the shelf comes in seconds. A book in the store room downstairs takes a few minutes, because someone has to walk down, find it and carry it up.
The shelf is full. A new book arrives that many readers want. Where does it go?

The librarian has to take a book off the shelf first. A sensible librarian takes the one nobody has asked for in the longest time. If she guesses wrong, the next reader who wants that book waits for the walk downstairs.
A computer that serves many machine learning models has the same problem. Its memory is the shelf. Its disk is the store room. Each model is a book. In this lesson I measure how big each book is, how many fit on one shelf, and what the walk downstairs costs, on a real rented computer.
This is lesson 10 of the chapter on serving a model. Serving a model means running it as a small program that answers questions while people wait.
The model is the features chapter's model. It looks at six numbers about one customer of a real online shop, such as the days since their last order. It gives a score between 0 and 1: how likely they are to buy again in the next 30 days.
The model is a tree model. A tree is a chain of yes or no questions about a customer, like a flowchart. The model asks many trees and adds up their answers.
Lesson 5, workers and threads, found that each copy of the service used about 220 MB of memory. Almost none of that was the model: the model file was only 0.2 MB. The rest was Python and its libraries. A library is a ready-made box of code that other programs use. That lesson had one model. This lesson asks what happens with many.
Why many models? A real company often has one model per country, per shop or per customer. Each one may be small, but there may be hundreds. Giving each its own computer is expensive. So the question is: how many models fit on one computer, and what happens when they do not?