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 33-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 cafe.
You order a meal at the counter. The waiter takes your order to the kitchen. Most days it comes back in two minutes. Today the kitchen is stuck, and your plate does not come.
What should the waiter do?
He could do nothing and let you stand there. You might wait twenty minutes. The people behind you wait too, because the waiter is busy with you.
He could come back after five minutes and say "sorry, no food today". You leave hungry, but at least you know.
He could come back after five minutes with something that is ready now: a sandwich from the fridge, or the same meal you had last week. It is not exactly what you asked for, but it is food, and it is on time.
He could also run back into the kitchen and shout the order again. If the kitchen is stuck because it is too busy, shouting every order twice makes it busier still.

A prediction service has the same problem. Before it can score a customer, it must fetch that customer's numbers from another system. Most of the time that takes two thousandths of a second. Sometimes it takes two whole seconds. In this lesson I measure what each of the waiter's choices does, on a real rented computer.
This is lesson 9 of the chapter on serving a model. It uses the same model and the same small web service as the lessons before it.
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.
How good is it? I measure that with AP, average precision. Think of a teacher ranking students for a prize: AP is high when the real winners are near the top of the list. On the months I kept aside for checking, this model's AP is 0.5450. Higher is better.
The service is the small web service from lesson 2, latency anatomy. A request comes in. The service looks up the customer's six numbers in a small database. The model scores them, and the answer goes back.
Lesson 7, load testing honestly, built the tester I use here: the program that sends requests and times each answer. Lesson 8 of the features chapter, missing at serving, measured what a model loses when a customer's numbers are missing. I lean on both and do not repeat them.
The machine has one core. A core is one worker inside a computer's chip, and it runs one program step at a time. My AWS account may rent only one core at a time, so, as in lessons 2 to 8, I rent a small computer with just one. The tester, the service and the slow database all share it.
The question: when the database the service depends on is slow, what should the service send back?