Machine learning models · Phase 7 · Lesson 57

Deployment, latency and cost

Design a serving path that meets accuracy, latency, reliability, privacy and cost requirements.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Design a serving path that meets accuracy, latency, reliability, privacy and cost requirements.

The core idea

A trained model is only one component. A deployed system also needs feature computation, versioning, transport, fallbacks and an owner.

Mental model

Picture it this way. A trained model is only one component. A deployed system also needs feature computation, versioning, transport, fallbacks and an owner. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

End-to-end latency includes queueing, feature retrieval, model inference and post-processing. Cost depends on request rate, hardware, model size, batching and availability targets.

Worked example

A fraud decision may need a result in 100 milliseconds. A large model with a slow feature lookup can fail the product even if its offline metric is higher.

When to use it

It earns a place when

  • Use a measured serving budget, batch or cache where appropriate, and choose a model whose worst-case behaviour fits the requirement.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not optimise average latency while ignoring p95 or p99, and do not deploy a model without a rollback and versioned feature contract.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Training-serving skew, cold starts, schema changes, dependency failures and silent fallback behaviour can corrupt outcomes.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Write a model-serving contract: input schema, output schema, latency budget, cost budget, timeout behaviour, fallback and rollback trigger.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What belongs in end-to-end latency?

2. Why monitor p95 or p99 latency?

3. What is training-serving skew?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

Google ML Crash Course. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.